From 3416919da668ea87abe09b6ec16195bedca94e87 Mon Sep 17 00:00:00 2001 From: baiqing Date: Sun, 3 May 2026 22:18:45 +0800 Subject: [PATCH] =?UTF-8?q?fix(asr):=20OpenAI=20=E5=85=BC=E5=AE=B9=20prese?= =?UTF-8?q?t=20=E4=B9=9F=E5=89=8D=E7=BD=AE=E6=A0=A1=E9=AA=8C=20endpoint=20?= =?UTF-8?q?=E4=B8=8E=20model?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-Agent #213 reviewer guide: 切到新 preset 后用户若手动清空 asr.endpoint,read_whisper_credentials 会返回空字符串, WhisperBatchASR 拼出相对路径 `/audio/transcriptions`,要等用户录完 才以 reqwest 错误失败。model 同理(兜底成 "whisper-1" 对 SiliconFlow 等是无效模型名,runtime 才 400)。 在 ensure_asr_credentials 的兼容分支里加前置校验,把错误时机提前到 按下热键的瞬间,复用与 api_key 同款 hard-error 语义。 --- openless-all/app/src-tauri/src/coordinator.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/openless-all/app/src-tauri/src/coordinator.rs b/openless-all/app/src-tauri/src/coordinator.rs index a2e6b4ea..7ac28249 100644 --- a/openless-all/app/src-tauri/src/coordinator.rs +++ b/openless-all/app/src-tauri/src/coordinator.rs @@ -1548,6 +1548,24 @@ fn ensure_asr_credentials() -> Result<(), String> { if api_key.trim().is_empty() { return Err("请先在设置中填写 ASR 服务商 API Key".to_string()); } + // 切换 preset 时前端会自动预填 endpoint/model,但用户可能手动清空。 + // 提前在这里报错,比录完后让 reqwest 拼出 `/audio/transcriptions` 相对路径 + // 再失败友好得多。model 同理:read_whisper_credentials 兜底成 "whisper-1", + // 对 SiliconFlow / GLM 等是错的,提前提示用户去填本厂商模型 ID。 + let endpoint = CredentialsVault::get(CredentialAccount::AsrEndpoint) + .ok() + .flatten() + .unwrap_or_default(); + if endpoint.trim().is_empty() { + return Err("请先在设置中填写 ASR 服务商接口地址".to_string()); + } + let model = CredentialsVault::get(CredentialAccount::AsrModel) + .ok() + .flatten() + .unwrap_or_default(); + if model.trim().is_empty() { + return Err("请先在设置中填写 ASR 模型名".to_string()); + } return Ok(()); }