fix(asr): OpenAI 兼容 preset 也前置校验 endpoint 与 model
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 语义。
This commit is contained in:
1 parent
0a4d33c755
commit
3416919da6
1 file changed
+18
@@ -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(());
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user