Fix Mistral provider: change api from openai-completions to mistral-conversations

This commit is contained in:
Pontoporeia
2026-05-01 22:39:11 +02:00
parent 34b2d073ee
commit d09f1942f0
3 changed files with 7 additions and 38 deletions

45
TODO.md
View File

@@ -1,40 +1,9 @@
# XAMXAM TODO
# TODO
## File Upload & Display System
- [x] Investigate Mistral API 404 error
- [x] Fix Mistral provider configuration (changed api to "mistral-conversations" and baseUrl to "https://api.mistral.ai")
- [x] **DB migration 007** — add `sort_order` and `display_label` columns to `thesis_files`
- [x] **Database.php**`getThesisFiles` ordered by `sort_order ASC`; `insertThesisFile` accepts `display_label` + `sort_order`; new `reorderThesisFiles()` and `updateThesisFileLabel()` methods
- [x] **ThesisCreateController** — expand MIME/ext allowlist (audio: mp3/ogg/wav/flac/aac/m4a; video: webm/mov/ogv; image: gif/webp; archives: tar/gz; any-ext via octet-stream); raise max size to 500 MB; accept `file_labels[]` and `file_orders[]` POST fields; `detectFileType()` helper
- [x] **ThesisEditController** — same expansions; handle `file_sort_order[]`, `file_label[id]` POST fields; reorder + label-update methods called; `detectFileType()` helper
- [x] **MediaController** — expanded MIME allowlist; HTTP Range support for audio/video seeking; force-download for "other" types; inline display for known displayable types
- [x] **fieldset-files.php** (shared partial) — replaced old multi-file input with sortable queue UI using SortableJS; per-file label inputs; wide accept attribute; 500 MB hint
- [x] **templates/admin/edit.php** — existing files rendered as sortable list with drag handles, file type icons, label inputs, delete checkboxes; hidden `file_sort_order[]` inputs; new-file queue widget
- [x] **file-upload-queue.js** — new JS: sortable queue for new uploads (SortableJS), per-file label fields, hidden order fields injected on submit; existing-file drag-sort; backward-compatible legacy preview for cover/banner inputs
- [x] **tfe.php** (public template) — handles audio (`<audio>`), video (all exts), image, PDF, "other" (download link); reads `display_label`; files already sorted by `sort_order`
- [x] **tfe.css** — styles for `.tfe-audio`, `.tfe-download-file`, `.tfe-download-link`
- [x] **form.css** — styles for `.tfe-file-queue`, `.fq-item`, `.admin-file-list-item` (sortable), drag handles, label inputs, ghost class
- [x] **PHP upload limits**`.htaccess` + `.user.ini` in `public/` (Apache/FPM) + `-d` flags in `justfile` serve recipe (built-in dev server ignores ini files)
- [x] **add.php / edit.php / partage/index.php** — use `sortable.min.js` + `file-upload-queue.js` instead of `file-preview.js`
- [x] **docs/file-uploads.md** — reference document covering accepted types, size limits, storage layout, ordering, labels, security, and source file index
## UI
- [x] **admin header** — replace "Déconnexion" text link with SVG sign-out icon (accessible via `aria-label` + `.sr-only` span)
- [x] **toast styling** — repositioned to bottom-center; solid `--bg-secondary` background; font bumped to `--step-0`; padding increased; visible duration extended to ~6.35 s; enter animation slides up from bottom
## Bug fixes
- [x] **smtp-test.php** — wrap `SmtpRelay::send()` in `try/catch SmtpSendException` so SMTP delivery failures (e.g. 550 recipient rejected) surface as a proper flash error instead of an uncaught exception/silent crash
- [x] **partage email retry** — on 550 recipient-rejected, redirect to `/partage/retry-email` instead of `recapitulatif`; student can correct address and resend or skip
- [x] **tfe access form email retry** — on `recipient_rejected` JSON response, highlight email field in red, show corrected error message, let user fix and resubmit inline
- [x] **ThesisCreateController**`confirmation_email` is now optional (empty = skip send)
- [x] **admin/add.php template** — email confirmation field marked optional, label and hint updated
## Previously completed
- [x] Multi-file upload for thesis files (basic)
- [x] File access restriction system (email approval workflow)
- [x] Share link system for student submission
- [x] Admin CRUD for theses
- [x] Public TFE detail page with file display
- [x] Search and repertoire
- [x] Tag management
- [x] Form help blocks
- [x] SMTP notification
## Issue Resolution
The Mistral provider had two configuration errors:
1. Used deprecated `api: "openai-completions"` instead of `api: "mistral-conversations"`
2. Incorrect baseUrl with `/v1` suffix. The Mistral SDK's `serverURL` expects the base URL without path suffixes - it appends the API paths internally. Changed from `https://api.mistral.ai/v1` to `https://api.mistral.ai`

Binary file not shown.