Fix 422 on text-only conversation turns

UploadFile | None = File(None) with from __future__ import annotations
caused FastAPI to still treat audio as required when omitted.
Changed to Optional[UploadFile] = None (no File() wrapper) so the
field is genuinely optional for text-input turns.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
mARTin-B78 2026-05-29 14:30:06 +02:00
parent 74e5181b7e
commit b3a408bfd9
2 changed files with 8 additions and 2 deletions

View File

@ -9,6 +9,11 @@ Follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) · versioned wi
### Fixed ### Fixed
- **Text-input turns returned 422**`UploadFile | None = File(None)` with
`from __future__ import annotations` caused FastAPI to treat `audio` as a
required field even when omitted. Changed to `Optional[UploadFile] = None`
(no `File()` wrapper) so the field is genuinely optional for text-only turns.
- **Conversation input bar hidden when mic unavailable** — the mic-blocked - **Conversation input bar hidden when mic unavailable** — the mic-blocked
warning box was inserted before `conv-chat-window` inside the flex column, warning box was inserted before `conv-chat-window` inside the flex column,
pushing the input bar off-screen. Fixed by prepending the warning inside pushing the input bar off-screen. Fixed by prepending the warning inside

View File

@ -11,7 +11,8 @@ import wave
from pathlib import Path from pathlib import Path
import requests import requests
from fastapi import APIRouter, File, Form, HTTPException, Request, UploadFile from typing import Optional
from fastapi import APIRouter, Form, HTTPException, Request, UploadFile
from fastapi.responses import Response, StreamingResponse from fastapi.responses import Response, StreamingResponse
from core.config import _load_settings, _save_settings, _clean_preview_backend from core.config import _load_settings, _save_settings, _clean_preview_backend
@ -659,7 +660,7 @@ async def conversation_llm_models(url: str = ""):
@router.post("/api/conversation/turn") @router.post("/api/conversation/turn")
async def conversation_turn( async def conversation_turn(
audio: UploadFile | None = File(None), audio: Optional[UploadFile] = None,
text: str = Form(""), text: str = Form(""),
stt_backend: str = Form("configured"), stt_backend: str = Form("configured"),
llm_url: str = Form(""), llm_url: str = Form(""),