feat(test): 模型测试支持故障转移,展示每次尝试详情

- 后端新增 test-model-failover 接口,支持 global/direct 两种测试模式
- 利用 FailoverEngine 遍历候选并记录每次尝试的状态、延迟、错误等详情
- 前端 ModelsTab/ModelMappingTab 切换到新接口,移除格式选择下拉菜单
- 新增 TestResultDialog 组件,失败时展示候选尝试详情表格
- 简化组件 props 传递,移除不再需要的 endpoints/mappingPreview 依赖
This commit is contained in:
fawney19
2026-03-01 03:37:41 +08:00
parent fea3d183bf
commit b61fc4eb6b
7 changed files with 786 additions and 242 deletions

View File

@@ -129,6 +129,48 @@ export async function testModel(data: TestModelRequest): Promise<TestModelRespon
return response.data
}
/**
* 带故障转移的模型测试
*/
export interface TestModelFailoverRequest {
provider_id: string
mode: 'global' | 'direct'
model_name: string
api_format?: string
message?: string
}
export interface TestAttemptDetail {
candidate_index: number
endpoint_api_format: string
endpoint_base_url: string
key_name: string | null
key_id: string
auth_type: string
effective_model?: string | null
status: 'success' | 'failed' | 'skipped'
skip_reason?: string | null
error_message?: string | null
status_code?: number | null
latency_ms?: number | null
}
export interface TestModelFailoverResponse {
success: boolean
model: string
provider: { id: string; name: string }
attempts: TestAttemptDetail[]
total_candidates: number
total_attempts: number
data?: Record<string, unknown> | null
error?: string | null
}
export async function testModelFailover(data: TestModelFailoverRequest): Promise<TestModelFailoverResponse> {
const response = await client.post('/api/admin/provider-query/test-model-failover', data)
return response.data
}
/**
* 映射预览相关类型
*/