forked from xiaohei/taiji-pda-v0
feat: 将供应商配置对话框的可调用模型输入框改为多选复选框
- 在 api-client.ts 中添加 getLiteLLMModels 和 getLiteLLMModelIds 方法 - 改为调用后端接口 /api/admin/resources/litellm-models 获取模型列表 - 移除前端直接调用 LiteLLM API 的敏感配置(API 密钥) - 将 providerForm.models 类型从 string 改为 string[] - 修改添加供应商对话框的 models 输入框为多选复选框列表 - 修改配置供应商对话框的 models 输入框为多选复选框列表 - 在打开对话框时自动加载 LiteLLM 模型列表
This commit is contained in:
+24
-31
@@ -2128,46 +2128,36 @@ export class TaijiAPIClient {
|
||||
return new WebSocket(`${wsUrl}/ws/${agentIdOrName}`)
|
||||
}
|
||||
|
||||
// ==================== LiteLLM API ====================
|
||||
// Base URL: https://litellm.graystone-fb459c5d.southeastasia.azurecontainerapps.io
|
||||
|
||||
/**
|
||||
* LiteLLM 服务配置
|
||||
*/
|
||||
static readonly LITELLM_CONFIG = {
|
||||
baseUrl: "https://litellm.graystone-fb459c5d.southeastasia.azurecontainerapps.io",
|
||||
apiKey: "sk-taiji-prod-2026",
|
||||
}
|
||||
// ==================== LiteLLM 模型列表 API ====================
|
||||
// 通过后端接口安全获取 LiteLLM 模型列表
|
||||
|
||||
/**
|
||||
* 获取 LiteLLM 可用模型列表
|
||||
* GET /v1/models
|
||||
* GET /api/admin/resources/litellm-models
|
||||
*
|
||||
* 返回所有可用的模型列表,用于供应商配置时选择可调用的模型
|
||||
* 从后端获取 LiteLLM Gateway 的所有可用模型列表,用于供应商配置时选择可调用的模型
|
||||
* 后端会安全地调用 LiteLLM API,避免在前端暴露 API 密钥
|
||||
*
|
||||
* @returns 模型列表,每个模型包含 id, object, created, owned_by 字段
|
||||
* @returns 模型列表响应,包含 models 数组、total 总数和 providers 供应商分组统计
|
||||
*/
|
||||
static async getLiteLLMModels(): Promise<{
|
||||
data: Array<{
|
||||
static async getLiteLLMModels(): Promise<APIResponse<{
|
||||
models: Array<{
|
||||
id: string
|
||||
name: string
|
||||
provider: string
|
||||
object: string
|
||||
created: number
|
||||
owned_by: string
|
||||
ownedBy: string
|
||||
}>
|
||||
object: string
|
||||
}> {
|
||||
const response = await fetch(`${this.LITELLM_CONFIG.baseUrl}/v1/models`, {
|
||||
headers: {
|
||||
"Authorization": `Bearer ${this.LITELLM_CONFIG.apiKey}`,
|
||||
"Accept": "application/json",
|
||||
},
|
||||
total: number
|
||||
providers: Array<{
|
||||
provider: string
|
||||
count: number
|
||||
}>
|
||||
}>> {
|
||||
const response = await fetch(`${API_BASE_URLS.mcpServer}/api/admin/resources/litellm-models`, {
|
||||
headers: buildHeaders(),
|
||||
})
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Failed to fetch LiteLLM models: ${response.status} ${response.statusText}`)
|
||||
}
|
||||
|
||||
return response.json()
|
||||
return handleResponse(response)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2179,6 +2169,9 @@ export class TaijiAPIClient {
|
||||
*/
|
||||
static async getLiteLLMModelIds(): Promise<string[]> {
|
||||
const result = await this.getLiteLLMModels()
|
||||
return result.data.map(model => model.id)
|
||||
if (result.success && result.data?.models) {
|
||||
return result.data.models.map(model => model.id)
|
||||
}
|
||||
return []
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user