mirror of
https://github.com/THU-MAIC/OpenMAIC.git
synced 2026-10-16 05:19:50 +08:00
* fix(asr): bypass AI SDK for custom providers to handle extra response fields Custom ASR providers (e.g. SiliconFlow) return OpenAI-compatible JSON but include extra fields like segments, duration, and usage that the Vercel AI SDK's strict Zod response schema does not expect, causing it to throw an 'Invalid JSON response' error. Previously, custom-asr-* providers were routed through transcribeOpenAIWhisper() which delegates to the AI SDK's experimental_transcribe. The SDK validates the raw HTTP response against a strict schema, so any provider-specific extra field fails parsing even when the ext value itself is perfectly valid. Fix: introduce transcribeCustomOpenAICompatibleASR() which calls /audio/transcriptions directly via raw fetch (the same approach already used by funasr-asr and lemonade-asr). It extracts only data.text from the response, making it tolerant of any extra fields a provider may return. The official openai-whisper case is unchanged and still uses the SDK. Fixes #1277 * style: fix prettier formatting in asr-providers.ts * fix(asr): require model ID for custom providers, add regression test Address review feedback from CXuPercy (#1283): - The previous implementation silently omitted the model FormData field when config.modelId was falsy. Most OpenAI-compatible transcription endpoints treat model as required, so a custom provider configured without a model ID would go from working (via transcribeOpenAIWhisper's fallback) to silently sending a modelless request and getting a 400. - Fix (Option A — fail fast): validate config.modelId before building the request and throw a descriptive error if it is missing, so the user gets a clear message rather than an opaque 400 from the upstream API. - UI contract: the settings panel already shows an amber warning 'Please add at least one model before using this provider' and the Add button is disabled when the model ID field is blank, so the UI is already aligned with the fail-fast behaviour. - Update all 12 test cases to supply a modelId, and add a dedicated regression test 'throws when no model ID is configured' to prevent this from regressing silently again.