feat(keys): 新增密钥自动获取模型功能

- 添加 auto_fetch_models 字段支持定时从上游 API 获取可用模型
- 添加 locked_models 字段支持锁定模型,刷新时不会被删除
- 新增 ModelFetchScheduler 调度器定期执行模型获取任务
- 前端 KeyFormDialog 添加自动获取模型开关
- 前端 KeyAllowedModelsEditDialog 支持模型锁定操作
- ProviderDetailDrawer 显示密钥同步状态
- 数据库迁移添加新字段
This commit is contained in:
fawney19
2026-01-14 13:12:19 +08:00
parent 3b194d3c23
commit a8813cfb89
14 changed files with 923 additions and 184 deletions

View File

@@ -95,6 +95,7 @@ export async function addProviderKey(
allowed_models?: AllowedModels
capabilities?: Record<string, boolean>
note?: string
auto_fetch_models?: boolean // 是否启用自动获取模型
}
): Promise<EndpointAPIKey> {
const response = await client.post(`/api/admin/endpoints/providers/${providerId}/keys`, data)
@@ -118,9 +119,11 @@ export async function updateProviderKey(
cache_ttl_minutes: number
max_probe_interval_minutes: number
allowed_models: AllowedModels
locked_models: string[] // 被锁定的模型列表
capabilities: Record<string, boolean> | null
is_active: boolean
note: string
auto_fetch_models: boolean // 是否启用自动获取模型
}>
): Promise<EndpointAPIKey> {
const response = await client.put(`/api/admin/endpoints/keys/${keyId}`, data)

View File

@@ -160,6 +160,11 @@ export interface EndpointAPIKey {
half_open_successes?: number
half_open_failures?: number
request_results_window?: Array<{ ts: number; ok: boolean }> // 请求结果滑动窗口
// 自动获取模型
auto_fetch_models?: boolean // 是否启用自动获取模型
last_models_fetch_at?: string // 最后获取模型时间
last_models_fetch_error?: string // 最后获取模型错误信息
locked_models?: string[] // 被锁定的模型列表
}
// 按格式的健康度数据
@@ -197,6 +202,8 @@ export interface EndpointAPIKeyUpdate {
max_probe_interval_minutes?: number
note?: string
is_active?: boolean
auto_fetch_models?: boolean // 是否启用自动获取模型
locked_models?: string[] // 被锁定的模型列表
}
export interface EndpointHealthDetail {