优化: Provider 配置体验(测试读表单值 + 保存反馈 + 报错友好 + 厂商预设,部分完成)
This commit is contained in:
@@ -204,6 +204,27 @@ export const aiApi = {
|
||||
return invoke('ai_fetch_models', { providerId })
|
||||
},
|
||||
|
||||
/**
|
||||
* 一次性测试连接(P0-1):用**表单当前值**测试,不写库。
|
||||
* - 新建态:传表单填的 providerType/baseUrl/apiKey,providerId=null。
|
||||
* - 编辑态(apiKey 留空=不改):传 providerId 让后端从 DB 沿用旧密钥;
|
||||
* apiKey 非空则直接用表单新值。
|
||||
* 成功返回模型列表(ModelConfig,不含 api_key),失败抛错。
|
||||
*/
|
||||
testConnection(input: {
|
||||
providerType: string
|
||||
baseUrl: string
|
||||
apiKey: string
|
||||
providerId?: string | null
|
||||
}): Promise<ModelConfig[]> {
|
||||
return invoke('ai_test_connection', {
|
||||
providerType: input.providerType,
|
||||
baseUrl: input.baseUrl,
|
||||
apiKey: input.apiKey,
|
||||
providerId: input.providerId ?? null,
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 单模型探测:纯 CPU 启发式 + 预设表,无网络。
|
||||
* 返回填充了 probe_source 的 ModelConfig。用途:手动补模型名后探测能力维度。
|
||||
|
||||
Reference in New Issue
Block a user