From 92c3173aec54c70ad959d0bf525c789097ae792c Mon Sep 17 00:00:00 2001 From: ssongliu Date: Fri, 13 Nov 2026 14:04:11 +0800 Subject: [PATCH] feat(ai): sync gateway providers and model discovery (#14426) * feat(ai): sync gateway providers and model discovery Add provider account types and protocol-aware model discovery, and replace predefined models with editable model pools. Align provider icons with AI Gateway, preserve international Coding Plan restrictions, and filter account counts consistently with selectable accounts. * fix(ai): preserve Ollama base paths during model discovery * fix(ai): restore custom DashScope image protocol support --- agent/app/api/v2/agents.go | 2 +- agent/app/dto/agents.go | 51 +- agent/app/model/agent_account.go | 1 + agent/app/provider/account_presets.go | 54 ++ agent/app/provider/catalog.go | 836 ++++++++++++------ agent/app/provider/discover.go | 187 +++- agent/app/provider/endpoint.go | 52 ++ agent/app/provider/minimax_test.go | 100 --- agent/app/provider/openclaw.go | 8 +- agent/app/provider/verify.go | 41 +- agent/app/repo/agent_account.go | 6 +- agent/app/repo/agent_account_model.go | 10 - agent/app/repo/common.go | 11 +- agent/app/service/agents.go | 167 ++-- agent/app/service/agents_hermes.go | 2 +- agent/app/service/agents_local.go | 28 + agent/app/service/agents_minimax_test.go | 115 --- agent/app/service/agents_utils.go | 78 +- agent/cmd/server/docs/x-log.json | 784 ++++++++-------- agent/init/migration/migrate.go | 1 + .../migrations/agent_account_type.go | 27 + .../utils/agent_account_model_pool.go | 11 +- agent/utils/terminal/ai/client.go | 87 +- agent/utils/terminal/ai/config_runtime.go | 18 +- core/cmd/server/docs/docs.go | 92 +- core/cmd/server/docs/swagger.json | 95 +- core/cmd/server/docs/x-log.json | 784 ++++++++-------- frontend/src/api/interface/ai.ts | 25 +- frontend/src/api/modules/ai.ts | 5 +- .../assets/images/ai-providers/deepseek.png | Bin 908 -> 0 bytes .../assets/images/ai-providers/deepseek.svg | 6 + .../src/assets/images/ai-providers/kimi.png | Bin 0 -> 4542 bytes .../src/assets/images/ai-providers/kimi.svg | 4 - .../assets/images/ai-providers/opencode.svg | 1 + .../assets/images/ai-providers/qianfan.svg | 1 + .../images/ai-providers/siliconflow.svg | 1 + .../images/ai-providers/tencentcloud.svg | 1 + frontend/src/lang/modules/en.ts | 27 + frontend/src/lang/modules/es-es.ts | 28 + frontend/src/lang/modules/fa.ts | 28 + frontend/src/lang/modules/ja.ts | 27 + frontend/src/lang/modules/ko.ts | 26 + frontend/src/lang/modules/lo.ts | 25 + frontend/src/lang/modules/ms.ts | 28 + frontend/src/lang/modules/pt-br.ts | 28 + frontend/src/lang/modules/ru.ts | 27 + frontend/src/lang/modules/tr.ts | 28 + frontend/src/lang/modules/zh-Hant.ts | 25 + frontend/src/lang/modules/zh.ts | 25 + frontend/src/utils/agent-provider-logo.ts | 42 +- .../src/views/ai/agents/agent/add/index.vue | 9 +- .../agent/config/tabs/agents/create/index.vue | 8 +- .../ai/agents/agent/config/tabs/model.vue | 8 +- .../src/views/ai/model/account-form/index.vue | 457 +++------- frontend/src/views/ai/model/index.vue | 10 +- .../src/views/ai/model/model-editor/index.vue | 276 ++++++ .../src/views/ai/model/model-pool/index.vue | 292 +++--- 57 files changed, 3026 insertions(+), 2090 deletions(-) create mode 100644 agent/app/provider/account_presets.go create mode 100644 agent/app/provider/endpoint.go delete mode 100644 agent/app/provider/minimax_test.go delete mode 100644 agent/app/service/agents_minimax_test.go create mode 100644 agent/init/migration/migrations/agent_account_type.go delete mode 100644 frontend/src/assets/images/ai-providers/deepseek.png create mode 100644 frontend/src/assets/images/ai-providers/deepseek.svg create mode 100644 frontend/src/assets/images/ai-providers/kimi.png delete mode 100644 frontend/src/assets/images/ai-providers/kimi.svg create mode 100644 frontend/src/assets/images/ai-providers/opencode.svg create mode 100644 frontend/src/assets/images/ai-providers/qianfan.svg create mode 100644 frontend/src/assets/images/ai-providers/siliconflow.svg create mode 100644 frontend/src/assets/images/ai-providers/tencentcloud.svg create mode 100644 frontend/src/views/ai/model/model-editor/index.vue diff --git a/agent/app/api/v2/agents.go b/agent/app/api/v2/agents.go index 831f6beb6..afbef9ea2 100644 --- a/agent/app/api/v2/agents.go +++ b/agent/app/api/v2/agents.go @@ -562,7 +562,7 @@ func (b *BaseApi) CreateAgentAccountModel(c *gin.Context) { } // @Tags AI -// @Summary Update model service model +// @Summary Update model service models // @Accept json // @Param request body dto.AgentAccountModelUpdateReq true "request" // @Success 200 diff --git a/agent/app/dto/agents.go b/agent/app/dto/agents.go index 1bfe3a8d0..e6d21fbe1 100644 --- a/agent/app/dto/agents.go +++ b/agent/app/dto/agents.go @@ -317,10 +317,13 @@ type AgentAccountVerifyModelUpdateReq struct { } type AgentAccountModelDiscoverReq struct { - Provider string `json:"provider" validate:"required"` - BaseURL string `json:"baseURL" validate:"required"` - APIKey string `json:"apiKey" validate:"required"` - APIType string `json:"apiType" validate:"required"` + AccountID uint `json:"accountId"` + AccountType string `json:"accountType"` + Provider string `json:"provider" validate:"required_without=AccountID"` + BaseURL string `json:"baseURL" validate:"required_without=AccountID"` + APIKey string `json:"apiKey" validate:"required_without=AccountID"` + APIType string `json:"apiType" validate:"required_without=AccountID"` + AuthMode string `json:"authMode"` } type AgentAccountModelCreateReq struct { @@ -330,8 +333,9 @@ type AgentAccountModelCreateReq struct { } type AgentAccountModelUpdateReq struct { - AccountID uint `json:"accountId" validate:"required"` - Model AgentAccountModel `json:"model" validate:"required"` + AccountID uint `json:"accountId" validate:"required"` + Models []AgentAccountModel `json:"models" validate:"required,min=1"` + VerifyModel string `json:"verifyModel"` } type AgentAccountModelDeleteReq struct { @@ -341,6 +345,7 @@ type AgentAccountModelDeleteReq struct { } type AgentAccountCreateReq struct { + AccountType string `json:"accountType"` Provider string `json:"provider" validate:"required"` Name string `json:"name" validate:"required"` APIKey string `json:"apiKey" validate:"required"` @@ -355,6 +360,7 @@ type AgentAccountCreateReq struct { } type AgentAccountUpdateReq struct { + AccountType string `json:"accountType"` ID uint `json:"id" validate:"required"` Name string `json:"name" validate:"required"` APIKey string `json:"apiKey" validate:"required"` @@ -385,17 +391,20 @@ type AgentAccountDeleteReq struct { type AgentAccountSearch struct { PageInfo - Provider string `json:"provider"` - APIType string `json:"apiType"` - TextOnly bool `json:"textOnly"` - Name string `json:"name"` + ExcludeCodingPlanProviders []string `json:"excludeCodingPlanProviders"` + Provider string `json:"provider"` + APIType string `json:"apiType"` + TextOnly bool `json:"textOnly"` + Name string `json:"name"` } type AgentAccountProviderCountReq struct { - Providers []string `json:"providers"` + ExcludeCodingPlanProviders []string `json:"excludeCodingPlanProviders"` + Providers []string `json:"providers"` } type AgentAccountInfo struct { + AccountType string `json:"accountType"` AppInstallID uint `json:"appInstallId"` ID uint `json:"id"` MasterAccountID uint `json:"masterAccountId"` @@ -433,13 +442,14 @@ type ProviderAPIInfo struct { } type ProviderInfo struct { - Sort uint `json:"-"` - Provider string `json:"provider"` - DisplayName string `json:"displayName"` - BaseURL string `json:"baseUrl"` - DefaultAPIType string `json:"defaultApiType"` - APITypes []ProviderAPIInfo `json:"apiTypes"` - Models []ProviderModelInfo `json:"models"` + AccountTypes []ProviderAccountTypeInfo `json:"accountTypes"` + Sort uint `json:"-"` + Provider string `json:"provider"` + DisplayName string `json:"displayName"` + BaseURL string `json:"baseUrl"` + DefaultAPIType string `json:"defaultApiType"` + APITypes []ProviderAPIInfo `json:"apiTypes"` + Models []ProviderModelInfo `json:"models"` } type AgentFeishuConfigReq struct { @@ -852,3 +862,8 @@ type AgentSkillUninstallReq struct { AgentID uint `json:"agentId" validate:"required"` Name string `json:"name" validate:"required"` } + +type ProviderAccountTypeInfo struct { + Key string `json:"key"` + APITypes []ProviderAPIInfo `json:"apiTypes"` +} diff --git a/agent/app/model/agent_account.go b/agent/app/model/agent_account.go index 4c46deaaf..15976dc6c 100644 --- a/agent/app/model/agent_account.go +++ b/agent/app/model/agent_account.go @@ -4,6 +4,7 @@ import "time" type AgentAccount struct { BaseModel + AccountType string `json:"accountType"` AppInstallID uint `json:"appInstallId"` Provider string `json:"provider"` Name string `json:"name"` diff --git a/agent/app/provider/account_presets.go b/agent/app/provider/account_presets.go new file mode 100644 index 000000000..cf15d8b0a --- /dev/null +++ b/agent/app/provider/account_presets.go @@ -0,0 +1,54 @@ +package provider + +import ( + "strings" +) + +type AccountTypePreset struct { + Key string `json:"key"` + APIConfigs []APIConfig `json:"apiTypes"` +} + +func FindAccountType(provider, accountType string) (AccountTypePreset, bool) { + meta, ok := catalog[provider] + if !ok || len(meta.AccountTypes) == 0 { + return AccountTypePreset{}, false + } + if accountType == "" { + switch provider { + case "bailian", "ark", "xiaomi": + accountType = "payAsYouGo" + case "kimi", "zai": + accountType = "chinaApi" + default: + return meta.AccountTypes[0], true + } + } + for _, item := range meta.AccountTypes { + if item.Key == accountType { + return item, true + } + } + return AccountTypePreset{}, false +} + +func Purpose(apiType string) string { + switch apiType { + case "openai-completions", "openai-responses", "anthropic-messages", "gemini-generate-content": + return "text" + case "openai-embeddings": + return "embedding" + case "rerank": + return "rerank" + } + if strings.HasSuffix(apiType, "-images") { + return "image" + } + if strings.HasSuffix(apiType, "-transcriptions") { + return "transcription" + } + if strings.HasSuffix(apiType, "-speech") { + return "speech" + } + return "" +} diff --git a/agent/app/provider/catalog.go b/agent/app/provider/catalog.go index a5a46d98b..66eff80b7 100644 --- a/agent/app/provider/catalog.go +++ b/agent/app/provider/catalog.go @@ -9,13 +9,17 @@ import ( ) type APIConfig struct { - APIType string - BaseURL string - EditableBaseURL bool - DiscoverModels bool - DefaultAuthMode string - AuthModes []string - Models []Model + Route string `json:"route"` + DiscoveryRoute string `json:"discoveryRoute"` + DiscoveryAuthMode string `json:"discoveryAuthMode"` + Purpose string `json:"purpose"` + Discovery string `json:"discovery"` + APIType string `json:"apiType"` + BaseURL string `json:"baseUrl"` + EditableBaseURL bool `json:"editableBaseUrl"` + DiscoverModels bool `json:"supportsModelDiscovery"` + DefaultAuthMode string `json:"defaultAuthMode"` + AuthModes []string `json:"authModes"` } const ( @@ -23,245 +27,598 @@ const ( AuthModeXAPIKey = "x-api-key" ) -type Model struct { - ID string - Name string -} - type Meta struct { + AccountTypes []AccountTypePreset Key string DisplayName string DisplayNameKey string Sort uint DefaultAPIType string - APIConfigs []APIConfig EnvKey string - Models []Model } var catalog = map[string]Meta{ "custom": { - Key: "custom", DisplayName: "Custom", Sort: 10, DefaultAPIType: "openai-completions", EnvKey: "CUSTOM_API_KEY", - APIConfigs: editableAPIConfigs(true, "openai-completions", "openai-responses", "anthropic-messages", "openai-images", "dashscope-images", "openai-embeddings"), + Key: "custom", + DisplayName: "Custom", + Sort: 10, + DefaultAPIType: "openai-completions", + EnvKey: "CUSTOM_API_KEY", + AccountTypes: []AccountTypePreset{ + { + Key: "default", + APIConfigs: []APIConfig{ + {APIType: "openai-completions", Purpose: "text", Route: "/v1", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/v1", DiscoveryAuthMode: "bearer", EditableBaseURL: true, DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "openai-responses", Purpose: "text", Route: "/v1", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/v1", DiscoveryAuthMode: "bearer", EditableBaseURL: true, DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "anthropic-messages", Purpose: "text", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/v1", DiscoveryAuthMode: "bearer", EditableBaseURL: true, DiscoverModels: true, DefaultAuthMode: "x-api-key", AuthModes: []string{"x-api-key", "bearer"}}, + {APIType: "openai-images", Purpose: "image", Route: "/v1", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/v1", DiscoveryAuthMode: "bearer", EditableBaseURL: true, DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "dashscope-images", Purpose: "image", Discovery: "DiscoveryNone", EditableBaseURL: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "openai-embeddings", Purpose: "embedding", Route: "/v1", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/v1", DiscoveryAuthMode: "bearer", EditableBaseURL: true, DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "rerank", Purpose: "rerank", Discovery: "DiscoveryNone", DiscoveryAuthMode: "bearer", EditableBaseURL: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "openai-transcriptions", Purpose: "transcription", Route: "/v1", Discovery: "DiscoveryNone", DiscoveryRoute: "/v1", DiscoveryAuthMode: "bearer", EditableBaseURL: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "openai-speech", Purpose: "speech", Route: "/v1", Discovery: "DiscoveryNone", DiscoveryRoute: "/v1", DiscoveryAuthMode: "bearer", EditableBaseURL: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + }, + }, + }, }, "ollama": { - Key: "ollama", DisplayName: "Ollama", Sort: 15, DefaultAPIType: "openai-responses", - APIConfigs: editableAPIConfigs(false, "openai-responses", "openai-completions", "openai-embeddings"), - }, - // llmman (https://github.com/llmmanorg/llmman): local runner with Ollama/OpenAI-compatible routes on 127.0.0.1:17434. - "llmman": { - Key: "llmman", DisplayName: "llmman", Sort: 75, DefaultAPIType: "openai-responses", - APIConfigs: []APIConfig{ - {APIType: "openai-responses", BaseURL: "http://127.0.0.1:17434/v1", EditableBaseURL: true}, - {APIType: "openai-completions", BaseURL: "http://127.0.0.1:17434/v1", EditableBaseURL: true}, - {APIType: "openai-embeddings", BaseURL: "http://127.0.0.1:17434/v1", EditableBaseURL: true}, + Key: "ollama", + DisplayName: "Ollama", + Sort: 40, + DefaultAPIType: "openai-responses", + AccountTypes: []AccountTypePreset{ + { + Key: "default", + APIConfigs: []APIConfig{ + {APIType: "openai-responses", Purpose: "text", Route: "/v1", Discovery: "DiscoveryOllamaModels", DiscoveryRoute: "/v1", DiscoveryAuthMode: "bearer", EditableBaseURL: true, DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "openai-completions", Purpose: "text", Route: "/v1", Discovery: "DiscoveryOllamaModels", DiscoveryRoute: "/v1", DiscoveryAuthMode: "bearer", EditableBaseURL: true, DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "anthropic-messages", Purpose: "text", Discovery: "DiscoveryOllamaModels", DiscoveryRoute: "/v1", DiscoveryAuthMode: "bearer", EditableBaseURL: true, DiscoverModels: true, DefaultAuthMode: "x-api-key", AuthModes: []string{"x-api-key"}}, + {APIType: "openai-images", Purpose: "image", Route: "/v1", Discovery: "DiscoveryOllamaModels", DiscoveryRoute: "/v1", DiscoveryAuthMode: "bearer", EditableBaseURL: true, DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "openai-embeddings", Purpose: "embedding", Route: "/v1", Discovery: "DiscoveryOllamaModels", DiscoveryRoute: "/v1", DiscoveryAuthMode: "bearer", EditableBaseURL: true, DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + }, + }, }, }, "vllm": { - Key: "vllm", DisplayName: "vLLM", Sort: 20, DefaultAPIType: "openai-completions", EnvKey: "VLLM_API_KEY", - APIConfigs: editableAPIConfigs(false, "openai-completions", "openai-responses", "anthropic-messages", "openai-images", "openai-embeddings"), + Key: "vllm", + DisplayName: "vLLM", + Sort: 20, + DefaultAPIType: "openai-completions", + EnvKey: "VLLM_API_KEY", + AccountTypes: []AccountTypePreset{ + { + Key: "default", + APIConfigs: []APIConfig{ + {APIType: "openai-completions", Purpose: "text", Route: "/v1", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/v1", DiscoveryAuthMode: "bearer", EditableBaseURL: true, DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "openai-responses", Purpose: "text", Route: "/v1", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/v1", DiscoveryAuthMode: "bearer", EditableBaseURL: true, DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "anthropic-messages", Purpose: "text", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/v1", DiscoveryAuthMode: "bearer", EditableBaseURL: true, DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer", "x-api-key"}}, + {APIType: "openai-images", Purpose: "image", Route: "/v1", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/v1", DiscoveryAuthMode: "bearer", EditableBaseURL: true, DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "openai-embeddings", Purpose: "embedding", Route: "/v1", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/v1", DiscoveryAuthMode: "bearer", EditableBaseURL: true, DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "rerank", Purpose: "rerank", Route: "/v1", Discovery: "DiscoveryNone", DiscoveryRoute: "/v1", DiscoveryAuthMode: "bearer", EditableBaseURL: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "openai-transcriptions", Purpose: "transcription", Route: "/v1", Discovery: "DiscoveryNone", DiscoveryRoute: "/v1", DiscoveryAuthMode: "bearer", EditableBaseURL: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + }, + }, + }, }, "1panel-ai-gateway": { - Key: "1panel-ai-gateway", DisplayName: "1Panel AI Gateway", DisplayNameKey: "AIProvider1PanelGateway", Sort: 21, DefaultAPIType: "openai-completions", EnvKey: "ONEPANEL_AI_GATEWAY_API_KEY", - APIConfigs: editableAPIConfigs(true, "openai-completions", "openai-responses", "anthropic-messages", "openai-images", "openai-embeddings"), + Key: "1panel-ai-gateway", + DisplayName: "1Panel AI Gateway", + DisplayNameKey: "AIProvider1PanelGateway", + Sort: 30, + DefaultAPIType: "openai-completions", + EnvKey: "ONEPANEL_AI_GATEWAY_API_KEY", + AccountTypes: []AccountTypePreset{ + { + Key: "default", + APIConfigs: []APIConfig{ + {APIType: "openai-completions", Purpose: "text", EditableBaseURL: true, DiscoverModels: true}, + {APIType: "openai-responses", Purpose: "text", EditableBaseURL: true, DiscoverModels: true}, + {APIType: "anthropic-messages", Purpose: "text", EditableBaseURL: true, DefaultAuthMode: "x-api-key", AuthModes: []string{"x-api-key", "bearer"}}, + {APIType: "openai-images", Purpose: "image", EditableBaseURL: true}, + {APIType: "openai-embeddings", Purpose: "embedding", EditableBaseURL: true}, + }, + }, + }, }, "deepseek": { - Key: "deepseek", DisplayName: "DeepSeek", Sort: 25, DefaultAPIType: "openai-completions", EnvKey: "DEEPSEEK_API_KEY", - APIConfigs: []APIConfig{ - {APIType: "openai-completions", BaseURL: "https://api.deepseek.com"}, - {APIType: "openai-responses", BaseURL: "https://api.deepseek.com"}, - anthropicAPIConfig("https://api.deepseek.com/anthropic", AuthModeXAPIKey), + Key: "deepseek", + DisplayName: "DeepSeek", + Sort: 60, + DefaultAPIType: "openai-completions", + EnvKey: "DEEPSEEK_API_KEY", + AccountTypes: []AccountTypePreset{ + { + Key: "default", + APIConfigs: []APIConfig{ + {APIType: "openai-completions", Purpose: "text", BaseURL: "https://api.deepseek.com", Discovery: "DiscoveryOpenAIModels", DiscoveryAuthMode: "bearer", DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "openai-responses", Purpose: "text", BaseURL: "https://api.deepseek.com", Discovery: "DiscoveryOpenAIModels", DiscoveryAuthMode: "bearer", DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "anthropic-messages", Purpose: "text", BaseURL: "https://api.deepseek.com/anthropic", Route: "/anthropic", Discovery: "DiscoveryOpenAIModels", DiscoveryAuthMode: "bearer", DiscoverModels: true, DefaultAuthMode: "x-api-key", AuthModes: []string{"x-api-key"}}, + }, + }, }, - Models: []Model{{ID: "deepseek-flash", Name: "deepseek-flash"}, {ID: "deepseek-v4-pro", Name: "deepseek-v4-pro"}}, }, "bailian-coding-plan": { - Key: "bailian-coding-plan", DisplayNameKey: "AIProviderBailianCodingPlan", Sort: 30, DefaultAPIType: "openai-completions", EnvKey: "QWEN_API_KEY", - APIConfigs: []APIConfig{ - {APIType: "openai-completions", BaseURL: "https://coding.dashscope.aliyuncs.com/v1"}, - anthropicAPIConfig("https://coding.dashscope.aliyuncs.com/apps/anthropic", AuthModeBearer), + Key: "bailian-coding-plan", + DisplayNameKey: "AIProviderBailianCodingPlan", + Sort: 210, + DefaultAPIType: "openai-completions", + EnvKey: "QWEN_API_KEY", + AccountTypes: []AccountTypePreset{ + { + Key: "codingPlan", + APIConfigs: []APIConfig{ + {APIType: "openai-completions", Purpose: "text", BaseURL: "https://coding.dashscope.aliyuncs.com/v1", Route: "/v1", Discovery: "DiscoveryNone", DiscoveryRoute: "/v1", DiscoveryAuthMode: "bearer", DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "anthropic-messages", Purpose: "text", BaseURL: "https://coding.dashscope.aliyuncs.com/apps/anthropic", Route: "/apps/anthropic", Discovery: "DiscoveryNone", DiscoveryRoute: "/v1", DiscoveryAuthMode: "bearer", DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + }, + }, }, - Models: []Model{ - {ID: "qwen3-coder-plus", Name: "Qwen3-Coder-Plus"}, - {ID: "qwen3-max-2026-01-23", Name: "Qwen3-Max-2026-01-23"}, - {ID: "qwen3-coder-next", Name: "Qwen3-Coder-Next"}, - {ID: "glm-4.7", Name: "GLM-4.7"}, - {ID: "kimi-k2.5", Name: "Kimi K2.5"}, - {ID: "qwen3.5-plus", Name: "Qwen3.5-Plus"}, - {ID: "glm-5", Name: "GLM-5"}, - {ID: "qwen3.6-plus", Name: "Qwen3.6-Plus"}, - {ID: "qwen3.7-plus", Name: "Qwen3.7-Plus"}, + }, + "bailian": { + Key: "bailian", + DisplayNameKey: "AIProviderBailian", + Sort: 80, + DefaultAPIType: "openai-completions", + EnvKey: "DASHSCOPE_API_KEY", + AccountTypes: []AccountTypePreset{ + { + Key: "codingPlan", + APIConfigs: []APIConfig{ + {APIType: "openai-completions", Purpose: "text", BaseURL: "https://coding.dashscope.aliyuncs.com/v1", Route: "/v1", Discovery: "DiscoveryNone", DiscoveryRoute: "/v1", DiscoveryAuthMode: "bearer", DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "anthropic-messages", Purpose: "text", BaseURL: "https://coding.dashscope.aliyuncs.com/apps/anthropic", Route: "/apps/anthropic", Discovery: "DiscoveryNone", DiscoveryRoute: "/v1", DiscoveryAuthMode: "bearer", DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + }, + }, + { + Key: "tokenPlan", + APIConfigs: []APIConfig{ + {APIType: "openai-completions", Purpose: "text", BaseURL: "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1", Route: "/compatible-mode/v1", Discovery: "DiscoveryNone", DiscoveryRoute: "/compatible-mode/v1", DiscoveryAuthMode: "bearer", DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "openai-responses", Purpose: "text", BaseURL: "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1", Route: "/compatible-mode/v1", Discovery: "DiscoveryNone", DiscoveryRoute: "/compatible-mode/v1", DiscoveryAuthMode: "bearer", DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "anthropic-messages", Purpose: "text", BaseURL: "https://token-plan.cn-beijing.maas.aliyuncs.com/apps/anthropic", Route: "/apps/anthropic", Discovery: "DiscoveryNone", DiscoveryRoute: "/compatible-mode/v1", DiscoveryAuthMode: "bearer", DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "dashscope-transcriptions", Purpose: "transcription", BaseURL: "https://token-plan.cn-beijing.maas.aliyuncs.com", Discovery: "DiscoveryNone", DiscoveryAuthMode: "bearer", DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "dashscope-speech", Purpose: "speech", BaseURL: "https://token-plan.cn-beijing.maas.aliyuncs.com", Discovery: "DiscoveryNone", DiscoveryAuthMode: "bearer", DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + }, + }, + { + Key: "payAsYouGo", + APIConfigs: []APIConfig{ + {APIType: "openai-completions", Purpose: "text", BaseURL: "https://dashscope.aliyuncs.com/compatible-mode/v1", Route: "/compatible-mode/v1", Discovery: "DiscoveryDashScopeModels", DiscoveryRoute: "/compatible-mode/v1", DiscoveryAuthMode: "bearer", EditableBaseURL: true, DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "openai-responses", Purpose: "text", BaseURL: "https://dashscope.aliyuncs.com/compatible-mode/v1", Route: "/compatible-mode/v1", Discovery: "DiscoveryDashScopeModels", DiscoveryRoute: "/compatible-mode/v1", DiscoveryAuthMode: "bearer", EditableBaseURL: true, DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "anthropic-messages", Purpose: "text", BaseURL: "https://dashscope.aliyuncs.com/apps/anthropic", Route: "/apps/anthropic", Discovery: "DiscoveryDashScopeModels", DiscoveryRoute: "/compatible-mode/v1", DiscoveryAuthMode: "bearer", EditableBaseURL: true, DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "dashscope-images", Purpose: "image", BaseURL: "https://dashscope.aliyuncs.com", Discovery: "DiscoveryDashScopeModels", DiscoveryAuthMode: "bearer", EditableBaseURL: true, DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "openai-embeddings", Purpose: "embedding", BaseURL: "https://dashscope.aliyuncs.com/compatible-mode/v1", Route: "/compatible-mode/v1", Discovery: "DiscoveryDashScopeModels", DiscoveryRoute: "/compatible-mode/v1", DiscoveryAuthMode: "bearer", EditableBaseURL: true, DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "rerank", Purpose: "rerank", BaseURL: "https://dashscope.aliyuncs.com", Discovery: "DiscoveryNone", DiscoveryAuthMode: "bearer", EditableBaseURL: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "dashscope-transcriptions", Purpose: "transcription", BaseURL: "https://dashscope.aliyuncs.com", Discovery: "DiscoveryDashScopeModels", DiscoveryAuthMode: "bearer", EditableBaseURL: true, DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "dashscope-speech", Purpose: "speech", BaseURL: "https://dashscope.aliyuncs.com", Discovery: "DiscoveryDashScopeModels", DiscoveryAuthMode: "bearer", EditableBaseURL: true, DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + }, + }, }, }, "ark-coding-plan": { - Key: "ark-coding-plan", DisplayNameKey: "AIProviderArkCodingPlan", Sort: 35, DefaultAPIType: "openai-completions", EnvKey: "ARK_API_KEY", - APIConfigs: []APIConfig{ - {APIType: "openai-completions", BaseURL: "https://ark.cn-beijing.volces.com/api/coding/v3"}, - anthropicAPIConfig("https://ark.cn-beijing.volces.com/api/coding", AuthModeBearer), - }, - Models: []Model{ - {ID: "ark-code-latest", Name: "Ark Coding Plan"}, {ID: "doubao-seed-code", Name: "Doubao Seed Code"}, - {ID: "glm-4.7", Name: "GLM 4.7 Coding"}, {ID: "kimi-k2-thinking", Name: "Kimi K2 Thinking"}, - {ID: "kimi-k2.5", Name: "Kimi K2.5 Coding"}, {ID: "doubao-seed-code-preview-251028", Name: "Doubao Seed Code Preview"}, - }, - }, - "zai": { - Key: "zai", DisplayName: "Z.ai", Sort: 40, DefaultAPIType: "openai-completions", EnvKey: "ZAI_API_KEY", - APIConfigs: []APIConfig{ - {APIType: "openai-completions", BaseURL: "https://open.bigmodel.cn/api/paas/v4", EditableBaseURL: true}, - {APIType: "openai-images", BaseURL: "https://open.bigmodel.cn/api/paas/v4", EditableBaseURL: true}, - }, - Models: []Model{{ID: "glm-5", Name: "GLM-5"}, {ID: "glm-4.7", Name: "GLM-4.7"}, {ID: "glm-4.7-flash", Name: "GLM-4.7-Flash"}, {ID: "glm-4.7-flashx", Name: "GLM-4.7-FlashX"}}, - }, - "minimax": { - Key: "minimax", DisplayName: "MiniMax (CN)", Sort: 45, DefaultAPIType: "anthropic-messages", EnvKey: "MINIMAX_API_KEY", - APIConfigs: []APIConfig{ - anthropicAPIConfig("https://api.minimaxi.com/anthropic", AuthModeXAPIKey, AuthModeBearer), - {APIType: "openai-completions", BaseURL: "https://api.minimaxi.com/v1"}, - {APIType: "minimax-images", BaseURL: "https://api.minimaxi.com"}, - }, - Models: []Model{{ID: "MiniMax-M3.1-Flash", Name: "MiniMax M3.1 Flash"}, {ID: "MiniMax-M3", Name: "MiniMax M3"}}, - }, - "xiaomi": { - Key: "xiaomi", DisplayName: "Xiaomi", Sort: 46, DefaultAPIType: "openai-completions", EnvKey: "XIAOMI_API_KEY", - APIConfigs: []APIConfig{ - {APIType: "openai-completions", BaseURL: "https://api.xiaomimimo.com/v1"}, - {APIType: "openai-responses", BaseURL: "https://api.xiaomimimo.com/v1"}, - anthropicAPIConfig("https://api.xiaomimimo.com/anthropic", AuthModeBearer), - }, - Models: []Model{{ID: "mimo-v2.5", Name: "Xiaomi MiMo V2.5"}, {ID: "mimo-v2.5-pro", Name: "Xiaomi MiMo V2.5 Pro"}}, - }, - "kimi": { - Key: "kimi", DisplayName: "Kimi (CN)", Sort: 50, DefaultAPIType: "openai-completions", EnvKey: "KIMI_API_KEY", - APIConfigs: []APIConfig{{APIType: "openai-completions", BaseURL: "https://api.moonshot.cn/v1"}}, - Models: []Model{{ID: "kimi-k2.5", Name: "Kimi K2.5"}, {ID: "kimi-k2-0905-preview", Name: "Kimi K2 0905 Preview"}, {ID: "kimi-k2-thinking", Name: "Kimi K2 Thinking"}}, - }, - "kimi-coding": { - Key: "kimi-coding", DisplayName: "Kimi Coding", Sort: 51, DefaultAPIType: "anthropic-messages", EnvKey: "KIMI_API_KEY", - APIConfigs: []APIConfig{anthropicAPIConfig("https://api.kimi.com/coding/", AuthModeXAPIKey)}, - Models: []Model{{ID: "kimi-code", Name: "Kimi Code"}, {ID: "k2p5", Name: "Kimi K2.5"}}, - }, - "openai": { - Key: "openai", DisplayName: "OpenAI", Sort: 55, DefaultAPIType: "openai-responses", EnvKey: "OPENAI_API_KEY", - APIConfigs: []APIConfig{ - {APIType: "openai-responses", BaseURL: "https://api.openai.com/v1"}, - {APIType: "openai-completions", BaseURL: "https://api.openai.com/v1"}, - {APIType: "openai-images", BaseURL: "https://api.openai.com/v1"}, - {APIType: "openai-embeddings", BaseURL: "https://api.openai.com/v1", Models: []Model{ - {ID: "text-embedding-3-small", Name: "text-embedding-3-small"}, - {ID: "text-embedding-3-large", Name: "text-embedding-3-large"}, - }}, - }, - Models: []Model{{ID: "gpt-5.4", Name: "gpt-5.4"}, {ID: "gpt-5.4-pro", Name: "gpt-5.4-pro"}, {ID: "gpt-5.4-mini", Name: "gpt-5.4-mini"}, {ID: "gpt-5.4-nano", Name: "gpt-5.4-nano"}}, - }, - "openrouter": { - Key: "openrouter", DisplayName: "OpenRouter", Sort: 56, DefaultAPIType: "openai-completions", EnvKey: "OPENROUTER_API_KEY", - APIConfigs: []APIConfig{ - {APIType: "openai-completions", BaseURL: "https://openrouter.ai/api/v1"}, - {APIType: "openrouter-images", BaseURL: "https://openrouter.ai"}, - }, - Models: []Model{{ID: "openrouter/free", Name: "openrouter/free"}, {ID: "openrouter/auto", Name: "openrouter/auto"}}, - }, - "anthropic": { - Key: "anthropic", DisplayName: "Anthropic", Sort: 60, DefaultAPIType: "anthropic-messages", EnvKey: "ANTHROPIC_API_KEY", - APIConfigs: []APIConfig{anthropicAPIConfig("https://api.anthropic.com", AuthModeXAPIKey)}, - Models: []Model{{ID: "claude-sonnet-4-6", Name: "Claude Sonnet 4.6"}, {ID: "claude-opus-4-6", Name: "Claude Opus 4.6"}, {ID: "claude-opus-4-5", Name: "Claude Opus 4.5"}, {ID: "claude-sonnet-4-5", Name: "Claude Sonnet 4.5"}, {ID: "claude-haiku-4-5", Name: "Claude Haiku 4.5"}}, - }, - "gemini": { - Key: "gemini", DisplayName: "Gemini", Sort: 65, DefaultAPIType: "gemini-generate-content", EnvKey: "GEMINI_API_KEY", - APIConfigs: []APIConfig{{APIType: "gemini-generate-content", BaseURL: "https://generativelanguage.googleapis.com"}}, - Models: []Model{{ID: "gemini-3-flash-preview", Name: "Gemini 3 Flash Preview"}, {ID: "gemini-flash-latest", Name: "Gemini Flash Latest"}, {ID: "gemini-3-pro-preview", Name: "Gemini 3 Pro Preview"}}, - }, - "moonshot": { - Key: "moonshot", DisplayName: "Moonshot (Global)", Sort: 70, DefaultAPIType: "openai-completions", EnvKey: "MOONSHOT_API_KEY", - APIConfigs: []APIConfig{{APIType: "openai-completions", BaseURL: "https://api.moonshot.ai/v1"}}, - Models: []Model{{ID: "kimi-k2.5", Name: "Kimi K2.5"}, {ID: "kimi-k2-0905-preview", Name: "Kimi K2 0905 Preview"}, {ID: "kimi-k2-thinking", Name: "Kimi K2 Thinking"}}, - }, - "bailian": { - Key: "bailian", DisplayNameKey: "AIProviderBailian", Sort: 31, DefaultAPIType: "openai-completions", EnvKey: "DASHSCOPE_API_KEY", - APIConfigs: []APIConfig{ + Key: "ark-coding-plan", + DisplayNameKey: "AIProviderArkCodingPlan", + Sort: 220, + DefaultAPIType: "openai-completions", + EnvKey: "ARK_API_KEY", + AccountTypes: []AccountTypePreset{ { - APIType: "openai-completions", BaseURL: "https://dashscope.aliyuncs.com/compatible-mode/v1", - DiscoverModels: true, - Models: []Model{{ID: "qwen3.7-plus", Name: "qwen3.7-plus"}, {ID: "qwen3.6-plus", Name: "qwen3.6-plus"}, {ID: "qwen3.6-flash", Name: "qwen3.6-flash"}}, - }, - { - APIType: "openai-responses", BaseURL: "https://dashscope.aliyuncs.com/compatible-mode/v1", - DiscoverModels: true, - Models: []Model{{ID: "qwen3.7-plus", Name: "qwen3.7-plus"}, {ID: "qwen3.6-plus", Name: "qwen3.6-plus"}, {ID: "qwen3.6-flash", Name: "qwen3.6-flash"}}, - }, - { - APIType: "anthropic-messages", BaseURL: "https://dashscope.aliyuncs.com/apps/anthropic", - DefaultAuthMode: AuthModeBearer, - AuthModes: []string{AuthModeBearer}, - Models: []Model{{ID: "qwen3.7-plus", Name: "qwen3.7-plus"}, {ID: "qwen3.6-plus", Name: "qwen3.6-plus"}, {ID: "qwen3.6-flash", Name: "qwen3.6-flash"}}, - }, - { - APIType: "dashscope-images", BaseURL: "https://dashscope.aliyuncs.com", - Models: []Model{ - {ID: "qwen-image-2.0-pro", Name: "qwen-image-2.0-pro"}, - {ID: "qwen-image-2.0", Name: "qwen-image-2.0"}, - {ID: "wan2.7-image-pro", Name: "wan2.7-image-pro"}, - {ID: "wan2.7-image", Name: "wan2.7-image"}, + Key: "codingPlan", + APIConfigs: []APIConfig{ + {APIType: "openai-completions", Purpose: "text", BaseURL: "https://ark.cn-beijing.volces.com/api/coding/v3", Route: "/api/coding/v3", Discovery: "DiscoveryNone", DiscoveryRoute: "/api/coding/v3", DiscoveryAuthMode: "bearer", DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "openai-responses", Purpose: "text", BaseURL: "https://ark.cn-beijing.volces.com/api/coding/v3", Route: "/api/coding/v3", Discovery: "DiscoveryNone", DiscoveryRoute: "/api/coding/v3", DiscoveryAuthMode: "bearer", DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "anthropic-messages", Purpose: "text", BaseURL: "https://ark.cn-beijing.volces.com/api/coding", Route: "/api/coding", Discovery: "DiscoveryNone", DiscoveryRoute: "/api/coding/v3", DiscoveryAuthMode: "bearer", DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "openai-embeddings", Purpose: "embedding", BaseURL: "https://ark.cn-beijing.volces.com/api/coding/v3", Route: "/api/coding/v3", Discovery: "DiscoveryNone", DiscoveryRoute: "/api/coding/v3", DiscoveryAuthMode: "bearer", DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, }, }, }, }, "ark": { - Key: "ark", DisplayNameKey: "AIProviderArk", Sort: 36, DefaultAPIType: "openai-completions", EnvKey: "ARK_API_KEY", - APIConfigs: []APIConfig{ + Key: "ark", + DisplayNameKey: "AIProviderArk", + Sort: 110, + DefaultAPIType: "openai-completions", + EnvKey: "ARK_API_KEY", + AccountTypes: []AccountTypePreset{ { - APIType: "openai-completions", BaseURL: "https://ark.cn-beijing.volces.com/api/v3", - DiscoverModels: true, - Models: []Model{{ID: "doubao-seed-2-0-pro-260215", Name: "doubao-seed-2-0-pro-260215"}, {ID: "doubao-seed-2-0-lite-260215", Name: "doubao-seed-2-0-lite-260215"}}, + Key: "codingPlan", + APIConfigs: []APIConfig{ + {APIType: "openai-completions", Purpose: "text", BaseURL: "https://ark.cn-beijing.volces.com/api/coding/v3", Route: "/api/coding/v3", Discovery: "DiscoveryNone", DiscoveryRoute: "/api/coding/v3", DiscoveryAuthMode: "bearer", DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "openai-responses", Purpose: "text", BaseURL: "https://ark.cn-beijing.volces.com/api/coding/v3", Route: "/api/coding/v3", Discovery: "DiscoveryNone", DiscoveryRoute: "/api/coding/v3", DiscoveryAuthMode: "bearer", DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "anthropic-messages", Purpose: "text", BaseURL: "https://ark.cn-beijing.volces.com/api/coding", Route: "/api/coding", Discovery: "DiscoveryNone", DiscoveryRoute: "/api/coding/v3", DiscoveryAuthMode: "bearer", DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "openai-embeddings", Purpose: "embedding", BaseURL: "https://ark.cn-beijing.volces.com/api/coding/v3", Route: "/api/coding/v3", Discovery: "DiscoveryNone", DiscoveryRoute: "/api/coding/v3", DiscoveryAuthMode: "bearer", DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + }, }, { - APIType: "openai-responses", BaseURL: "https://ark.cn-beijing.volces.com/api/v3", - DiscoverModels: true, - Models: []Model{{ID: "doubao-seed-2-0-pro-260215", Name: "doubao-seed-2-0-pro-260215"}, {ID: "doubao-seed-2-0-lite-260215", Name: "doubao-seed-2-0-lite-260215"}}, + Key: "agentPlan", + APIConfigs: []APIConfig{ + {APIType: "openai-completions", Purpose: "text", BaseURL: "https://ark.cn-beijing.volces.com/api/plan/v3", Route: "/api/plan/v3", Discovery: "DiscoveryNone", DiscoveryRoute: "/api/plan/v3", DiscoveryAuthMode: "bearer", DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "openai-responses", Purpose: "text", BaseURL: "https://ark.cn-beijing.volces.com/api/plan/v3", Route: "/api/plan/v3", Discovery: "DiscoveryNone", DiscoveryRoute: "/api/plan/v3", DiscoveryAuthMode: "bearer", DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "anthropic-messages", Purpose: "text", BaseURL: "https://ark.cn-beijing.volces.com/api/plan", Route: "/api/plan", Discovery: "DiscoveryNone", DiscoveryRoute: "/api/plan/v3", DiscoveryAuthMode: "bearer", DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "openai-images", Purpose: "image", BaseURL: "https://ark.cn-beijing.volces.com/api/plan/v3", Route: "/api/plan/v3", Discovery: "DiscoveryNone", DiscoveryRoute: "/api/plan/v3", DiscoveryAuthMode: "bearer", DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "openai-embeddings", Purpose: "embedding", BaseURL: "https://ark.cn-beijing.volces.com/api/plan/v3", Route: "/api/plan/v3", Discovery: "DiscoveryNone", DiscoveryRoute: "/api/plan/v3", DiscoveryAuthMode: "bearer", DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + }, }, { - APIType: "openai-images", BaseURL: "https://ark.cn-beijing.volces.com/api/v3", - Models: []Model{ - {ID: "doubao-seedream-5-0-260128", Name: "doubao-seedream-5-0-260128"}, - {ID: "doubao-seedream-5-0-lite-260128", Name: "doubao-seedream-5-0-lite-260128"}, - {ID: "doubao-seedream-4-5-251128", Name: "doubao-seedream-4-5-251128"}, + Key: "payAsYouGo", + APIConfigs: []APIConfig{ + {APIType: "openai-completions", Purpose: "text", BaseURL: "https://ark.cn-beijing.volces.com/api/v3", Route: "/api/v3", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/api/v3", DiscoveryAuthMode: "bearer", DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "openai-responses", Purpose: "text", BaseURL: "https://ark.cn-beijing.volces.com/api/v3", Route: "/api/v3", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/api/v3", DiscoveryAuthMode: "bearer", DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "openai-images", Purpose: "image", BaseURL: "https://ark.cn-beijing.volces.com/api/v3", Route: "/api/v3", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/api/v3", DiscoveryAuthMode: "bearer", DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "openai-embeddings", Purpose: "embedding", BaseURL: "https://ark.cn-beijing.volces.com/api/v3", Route: "/api/v3", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/api/v3", DiscoveryAuthMode: "bearer", DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + }, + }, + { + Key: "speech", + APIConfigs: []APIConfig{ + {APIType: "doubao-transcriptions", Purpose: "transcription", BaseURL: "https://openspeech.bytedance.com", Discovery: "DiscoveryNone", DiscoveryAuthMode: "x-api-key", DefaultAuthMode: "x-api-key", AuthModes: []string{"x-api-key"}}, + {APIType: "doubao-speech", Purpose: "speech", BaseURL: "https://openspeech.bytedance.com", Discovery: "DiscoveryNone", DiscoveryAuthMode: "x-api-key", DefaultAuthMode: "x-api-key", AuthModes: []string{"x-api-key"}}, + }, + }, + }, + }, + "zai": { + Key: "zai", + DisplayName: "Z.ai", + Sort: 120, + DefaultAPIType: "openai-completions", + EnvKey: "ZAI_API_KEY", + AccountTypes: []AccountTypePreset{ + { + Key: "chinaCodingPlan", + APIConfigs: []APIConfig{ + {APIType: "openai-completions", Purpose: "text", BaseURL: "https://open.bigmodel.cn/api/coding/paas/v4", Route: "/api/coding/paas/v4", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/api/coding/paas/v4", DiscoveryAuthMode: "bearer", DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "anthropic-messages", Purpose: "text", BaseURL: "https://open.bigmodel.cn/api/anthropic", Route: "/api/anthropic", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/api/coding/paas/v4", DiscoveryAuthMode: "bearer", DiscoverModels: true, DefaultAuthMode: "x-api-key", AuthModes: []string{"x-api-key"}}, + }, + }, + { + Key: "globalCodingPlan", + APIConfigs: []APIConfig{ + {APIType: "openai-completions", Purpose: "text", BaseURL: "https://api.z.ai/api/coding/paas/v4", Route: "/api/coding/paas/v4", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/api/coding/paas/v4", DiscoveryAuthMode: "bearer", DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "anthropic-messages", Purpose: "text", BaseURL: "https://api.z.ai/api/anthropic", Route: "/api/anthropic", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/api/coding/paas/v4", DiscoveryAuthMode: "bearer", DiscoverModels: true, DefaultAuthMode: "x-api-key", AuthModes: []string{"x-api-key"}}, + }, + }, + { + Key: "chinaApi", + APIConfigs: []APIConfig{ + {APIType: "openai-completions", Purpose: "text", BaseURL: "https://open.bigmodel.cn/api/paas/v4", Route: "/api/paas/v4", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/api/paas/v4", DiscoveryAuthMode: "bearer", DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "anthropic-messages", Purpose: "text", BaseURL: "https://open.bigmodel.cn/api/anthropic", Route: "/api/anthropic", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/api/paas/v4", DiscoveryAuthMode: "bearer", DiscoverModels: true, DefaultAuthMode: "x-api-key", AuthModes: []string{"x-api-key"}}, + {APIType: "openai-images", Purpose: "image", BaseURL: "https://open.bigmodel.cn/api/paas/v4", Route: "/api/paas/v4", Discovery: "DiscoveryNone", DiscoveryRoute: "/api/paas/v4", DiscoveryAuthMode: "bearer", DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "rerank", Purpose: "rerank", BaseURL: "https://open.bigmodel.cn/api/paas/v4", Route: "/api/paas/v4", Discovery: "DiscoveryNone", DiscoveryRoute: "/api/paas/v4", DiscoveryAuthMode: "bearer", DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + }, + }, + { + Key: "globalApi", + APIConfigs: []APIConfig{ + {APIType: "openai-completions", Purpose: "text", BaseURL: "https://api.z.ai/api/paas/v4", Route: "/api/paas/v4", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/api/paas/v4", DiscoveryAuthMode: "bearer", DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "anthropic-messages", Purpose: "text", BaseURL: "https://api.z.ai/api/anthropic", Route: "/api/anthropic", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/api/paas/v4", DiscoveryAuthMode: "bearer", DiscoverModels: true, DefaultAuthMode: "x-api-key", AuthModes: []string{"x-api-key"}}, + {APIType: "openai-images", Purpose: "image", BaseURL: "https://api.z.ai/api/paas/v4", Route: "/api/paas/v4", Discovery: "DiscoveryNone", DiscoveryRoute: "/api/paas/v4", DiscoveryAuthMode: "bearer", DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + }, + }, + }, + }, + "minimax": { + Key: "minimax", + DisplayName: "MiniMax (CN)", + Sort: 130, + DefaultAPIType: "anthropic-messages", + EnvKey: "MINIMAX_API_KEY", + AccountTypes: []AccountTypePreset{ + { + Key: "default", + APIConfigs: []APIConfig{ + {APIType: "anthropic-messages", Purpose: "text", BaseURL: "https://api.minimaxi.com/anthropic", Route: "/anthropic", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/anthropic", DiscoveryAuthMode: "x-api-key", DiscoverModels: true, DefaultAuthMode: "x-api-key", AuthModes: []string{"x-api-key", "bearer"}}, + {APIType: "openai-completions", Purpose: "text", BaseURL: "https://api.minimaxi.com/v1", Route: "/v1", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/anthropic", DiscoveryAuthMode: "x-api-key", DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "openai-responses", Purpose: "text", BaseURL: "https://api.minimaxi.com/v1", Route: "/v1", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/anthropic", DiscoveryAuthMode: "x-api-key", DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "minimax-images", Purpose: "image", BaseURL: "https://api.minimaxi.com", Discovery: "DiscoveryNone", DiscoveryAuthMode: "bearer", DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "minimax-speech", Purpose: "speech", BaseURL: "https://api.minimaxi.com", Discovery: "DiscoveryNone", DiscoveryAuthMode: "bearer", DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + }, + }, + }, + }, + "xiaomi": { + Key: "xiaomi", + DisplayName: "Xiaomi", + Sort: 140, + DefaultAPIType: "openai-completions", + EnvKey: "XIAOMI_API_KEY", + AccountTypes: []AccountTypePreset{ + { + Key: "tokenPlan", + APIConfigs: []APIConfig{ + {APIType: "openai-completions", Purpose: "text", BaseURL: "https://token-plan-cn.xiaomimimo.com/v1", Route: "/v1", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/v1", DiscoveryAuthMode: "bearer", EditableBaseURL: true, DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "openai-responses", Purpose: "text", BaseURL: "https://token-plan-cn.xiaomimimo.com/v1", Route: "/v1", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/v1", DiscoveryAuthMode: "bearer", EditableBaseURL: true, DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "anthropic-messages", Purpose: "text", BaseURL: "https://token-plan-cn.xiaomimimo.com/anthropic", Route: "/anthropic", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/v1", DiscoveryAuthMode: "bearer", EditableBaseURL: true, DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + }, + }, + { + Key: "payAsYouGo", + APIConfigs: []APIConfig{ + {APIType: "openai-completions", Purpose: "text", BaseURL: "https://api.xiaomimimo.com/v1", Route: "/v1", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/v1", DiscoveryAuthMode: "bearer", DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "openai-responses", Purpose: "text", BaseURL: "https://api.xiaomimimo.com/v1", Route: "/v1", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/v1", DiscoveryAuthMode: "bearer", DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "anthropic-messages", Purpose: "text", BaseURL: "https://api.xiaomimimo.com/anthropic", Route: "/anthropic", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/v1", DiscoveryAuthMode: "bearer", DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "mimo-transcriptions", Purpose: "transcription", BaseURL: "https://api.xiaomimimo.com/v1", Route: "/v1", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/v1", DiscoveryAuthMode: "bearer", DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "mimo-speech", Purpose: "speech", BaseURL: "https://api.xiaomimimo.com/v1", Route: "/v1", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/v1", DiscoveryAuthMode: "bearer", DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + }, + }, + }, + }, + "kimi": { + Key: "kimi", + DisplayName: "Kimi (CN)", + Sort: 150, + DefaultAPIType: "openai-completions", + EnvKey: "KIMI_API_KEY", + AccountTypes: []AccountTypePreset{ + { + Key: "chinaTokenPlan", + APIConfigs: []APIConfig{ + {APIType: "openai-completions", Purpose: "text", BaseURL: "https://api.kimi.com/coding/v1", Route: "/coding/v1", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/coding/v1", DiscoveryAuthMode: "bearer", DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "anthropic-messages", Purpose: "text", BaseURL: "https://api.kimi.com/coding", Route: "/coding", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/coding/v1", DiscoveryAuthMode: "bearer", DiscoverModels: true, DefaultAuthMode: "x-api-key", AuthModes: []string{"x-api-key", "bearer"}}, + }, + }, + { + Key: "globalTokenPlan", + APIConfigs: []APIConfig{ + {APIType: "openai-completions", Purpose: "text", BaseURL: "https://api.kimi.com/coding/v1", Route: "/coding/v1", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/coding/v1", DiscoveryAuthMode: "bearer", DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "anthropic-messages", Purpose: "text", BaseURL: "https://api.kimi.com/coding", Route: "/coding", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/coding/v1", DiscoveryAuthMode: "bearer", DiscoverModels: true, DefaultAuthMode: "x-api-key", AuthModes: []string{"x-api-key", "bearer"}}, + }, + }, + { + Key: "chinaApi", + APIConfigs: []APIConfig{ + {APIType: "openai-completions", Purpose: "text", BaseURL: "https://api.moonshot.cn/v1", Route: "/v1", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/v1", DiscoveryAuthMode: "bearer", DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "anthropic-messages", Purpose: "text", BaseURL: "https://api.moonshot.cn/anthropic", Route: "/anthropic", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/v1", DiscoveryAuthMode: "bearer", DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + }, + }, + { + Key: "globalApi", + APIConfigs: []APIConfig{ + {APIType: "openai-completions", Purpose: "text", BaseURL: "https://api.moonshot.ai/v1", Route: "/v1", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/v1", DiscoveryAuthMode: "bearer", DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "anthropic-messages", Purpose: "text", BaseURL: "https://api.moonshot.ai/anthropic", Route: "/anthropic", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/v1", DiscoveryAuthMode: "bearer", DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + }, + }, + }, + }, + "kimi-coding": { + Key: "kimi-coding", + DisplayName: "Kimi Coding", + Sort: 230, + DefaultAPIType: "anthropic-messages", + EnvKey: "KIMI_API_KEY", + AccountTypes: []AccountTypePreset{ + { + Key: "chinaTokenPlan", + APIConfigs: []APIConfig{ + {APIType: "openai-completions", Purpose: "text", BaseURL: "https://api.kimi.com/coding/v1", Route: "/coding/v1", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/coding/v1", DiscoveryAuthMode: "bearer", DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "anthropic-messages", Purpose: "text", BaseURL: "https://api.kimi.com/coding", Route: "/coding", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/coding/v1", DiscoveryAuthMode: "bearer", DiscoverModels: true, DefaultAuthMode: "x-api-key", AuthModes: []string{"x-api-key", "bearer"}}, + }, + }, + }, + }, + "openai": { + Key: "openai", + DisplayName: "OpenAI", + Sort: 170, + DefaultAPIType: "openai-responses", + EnvKey: "OPENAI_API_KEY", + AccountTypes: []AccountTypePreset{ + { + Key: "default", + APIConfigs: []APIConfig{ + {APIType: "openai-responses", Purpose: "text", BaseURL: "https://api.openai.com/v1", Route: "/v1", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/v1", DiscoveryAuthMode: "bearer", DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "openai-completions", Purpose: "text", BaseURL: "https://api.openai.com/v1", Route: "/v1", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/v1", DiscoveryAuthMode: "bearer", DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "openai-images", Purpose: "image", BaseURL: "https://api.openai.com/v1", Route: "/v1", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/v1", DiscoveryAuthMode: "bearer", DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "openai-embeddings", Purpose: "embedding", BaseURL: "https://api.openai.com/v1", Route: "/v1", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/v1", DiscoveryAuthMode: "bearer", DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "openai-transcriptions", Purpose: "transcription", BaseURL: "https://api.openai.com/v1", Route: "/v1", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/v1", DiscoveryAuthMode: "bearer", DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "openai-speech", Purpose: "speech", BaseURL: "https://api.openai.com/v1", Route: "/v1", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/v1", DiscoveryAuthMode: "bearer", DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + }, + }, + }, + }, + "openrouter": { + Key: "openrouter", + DisplayName: "OpenRouter", + Sort: 180, + DefaultAPIType: "openai-completions", + EnvKey: "OPENROUTER_API_KEY", + AccountTypes: []AccountTypePreset{ + { + Key: "default", + APIConfigs: []APIConfig{ + {APIType: "openai-completions", Purpose: "text", BaseURL: "https://openrouter.ai/api/v1", Route: "/api/v1", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/api/v1", DiscoveryAuthMode: "bearer", DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "openai-responses", Purpose: "text", BaseURL: "https://openrouter.ai/api/v1", Route: "/api/v1", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/api/v1", DiscoveryAuthMode: "bearer", DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "anthropic-messages", Purpose: "text", BaseURL: "https://openrouter.ai/api", Route: "/api", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/api/v1", DiscoveryAuthMode: "bearer", DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "openrouter-images", Purpose: "image", BaseURL: "https://openrouter.ai", Discovery: "DiscoveryOpenAIModels", DiscoveryAuthMode: "bearer", DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "openai-embeddings", Purpose: "embedding", BaseURL: "https://openrouter.ai/api/v1", Route: "/api/v1", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/api/v1", DiscoveryAuthMode: "bearer", DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "rerank", Purpose: "rerank", BaseURL: "https://openrouter.ai/api/v1", Route: "/api/v1", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/api/v1", DiscoveryAuthMode: "bearer", DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "openai-transcriptions", Purpose: "transcription", BaseURL: "https://openrouter.ai/api/v1", Route: "/api/v1", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/api/v1", DiscoveryAuthMode: "bearer", DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "openai-speech", Purpose: "speech", BaseURL: "https://openrouter.ai/api/v1", Route: "/api/v1", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/api/v1", DiscoveryAuthMode: "bearer", DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + }, + }, + }, + }, + "anthropic": { + Key: "anthropic", + DisplayName: "Anthropic", + Sort: 190, + DefaultAPIType: "anthropic-messages", + EnvKey: "ANTHROPIC_API_KEY", + AccountTypes: []AccountTypePreset{ + { + Key: "default", + APIConfigs: []APIConfig{ + {APIType: "anthropic-messages", Purpose: "text", BaseURL: "https://api.anthropic.com", Discovery: "DiscoveryAnthropicModels", DiscoveryAuthMode: "x-api-key", DiscoverModels: true, DefaultAuthMode: "x-api-key", AuthModes: []string{"x-api-key"}}, + }, + }, + }, + }, + "gemini": { + Key: "gemini", + DisplayName: "Gemini", + Sort: 200, + DefaultAPIType: "gemini-generate-content", + EnvKey: "GEMINI_API_KEY", + AccountTypes: []AccountTypePreset{ + { + Key: "default", + APIConfigs: []APIConfig{ + {APIType: "gemini-generate-content", Purpose: "text", BaseURL: "https://generativelanguage.googleapis.com", Discovery: "DiscoveryGeminiModels", DiscoveryAuthMode: "x-goog-api-key", DiscoverModels: true, DefaultAuthMode: "x-goog-api-key", AuthModes: []string{"x-goog-api-key"}}, + {APIType: "openai-completions", Purpose: "text", BaseURL: "https://generativelanguage.googleapis.com/v1beta/openai", Route: "/v1beta/openai", Discovery: "DiscoveryGeminiModels", DiscoveryAuthMode: "x-goog-api-key", DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "gemini-speech", Purpose: "speech", BaseURL: "https://generativelanguage.googleapis.com", Discovery: "DiscoveryGeminiModels", DiscoveryAuthMode: "x-goog-api-key", DiscoverModels: true, DefaultAuthMode: "x-goog-api-key", AuthModes: []string{"x-goog-api-key"}}, + }, + }, + }, + }, + "moonshot": { + Key: "moonshot", + DisplayName: "Moonshot (Global)", + Sort: 240, + DefaultAPIType: "openai-completions", + EnvKey: "MOONSHOT_API_KEY", + AccountTypes: []AccountTypePreset{ + { + Key: "globalApi", + APIConfigs: []APIConfig{ + {APIType: "openai-completions", Purpose: "text", BaseURL: "https://api.moonshot.ai/v1", Route: "/v1", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/v1", DiscoveryAuthMode: "bearer", DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "anthropic-messages", Purpose: "text", BaseURL: "https://api.moonshot.ai/anthropic", Route: "/anthropic", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/v1", DiscoveryAuthMode: "bearer", DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + }, + }, + }, + }, + "llmman": { + Key: "llmman", + DisplayName: "llmman", + Sort: 250, + DefaultAPIType: "openai-responses", + AccountTypes: []AccountTypePreset{ + { + Key: "default", + APIConfigs: []APIConfig{ + {APIType: "openai-responses", Purpose: "text", BaseURL: "http://127.0.0.1:17434/v1", EditableBaseURL: true, DiscoverModels: true}, + {APIType: "openai-completions", Purpose: "text", BaseURL: "http://127.0.0.1:17434/v1", EditableBaseURL: true, DiscoverModels: true}, + {APIType: "openai-embeddings", Purpose: "embedding", BaseURL: "http://127.0.0.1:17434/v1", EditableBaseURL: true}, + }, + }, + }, + }, + "tokenhub": { + Key: "tokenhub", + DisplayName: "TokenHub", + Sort: 70, + DefaultAPIType: "openai-completions", + AccountTypes: []AccountTypePreset{ + { + Key: "chinaTokenPlan", + APIConfigs: []APIConfig{ + {APIType: "openai-completions", Purpose: "text", BaseURL: "https://tokenhub.tencentmaas.com/plan/v3", Route: "/v3", Discovery: "DiscoveryNone", DiscoveryRoute: "/v3", DiscoveryAuthMode: "bearer", DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "anthropic-messages", Purpose: "text", BaseURL: "https://tokenhub.tencentmaas.com/plan/anthropic", Route: "/anthropic", Discovery: "DiscoveryNone", DiscoveryRoute: "/v3", DiscoveryAuthMode: "bearer", DefaultAuthMode: "x-api-key", AuthModes: []string{"x-api-key"}}, + }, + }, + { + Key: "globalTokenPlan", + APIConfigs: []APIConfig{ + {APIType: "openai-completions", Purpose: "text", BaseURL: "https://tokenhub-intl.tencentmaas.com/plan/v3", Route: "/v3", Discovery: "DiscoveryNone", DiscoveryRoute: "/v3", DiscoveryAuthMode: "bearer", DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "anthropic-messages", Purpose: "text", BaseURL: "https://tokenhub-intl.tencentmaas.com/plan/anthropic", Route: "/anthropic", Discovery: "DiscoveryNone", DiscoveryRoute: "/v3", DiscoveryAuthMode: "bearer", DefaultAuthMode: "x-api-key", AuthModes: []string{"x-api-key"}}, + }, + }, + { + Key: "chinaApi", + APIConfigs: []APIConfig{ + {APIType: "openai-completions", Purpose: "text", BaseURL: "https://tokenhub.tencentmaas.com/v1", Route: "/v1", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/v1", DiscoveryAuthMode: "bearer", DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "openai-responses", Purpose: "text", BaseURL: "https://tokenhub.tencentmaas.com/v1", Route: "/v1", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/v1", DiscoveryAuthMode: "bearer", DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "anthropic-messages", Purpose: "text", BaseURL: "https://tokenhub.tencentmaas.com", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/v1", DiscoveryAuthMode: "bearer", DiscoverModels: true, DefaultAuthMode: "x-api-key", AuthModes: []string{"x-api-key"}}, + {APIType: "tokenhub-images", Purpose: "image", BaseURL: "https://tokenhub.tencentmaas.com", Discovery: "DiscoveryOpenAIModels", DiscoveryAuthMode: "bearer", DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "openai-embeddings", Purpose: "embedding", BaseURL: "https://tokenhub.tencentmaas.com/v1", Route: "/v1", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/v1", DiscoveryAuthMode: "bearer", DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "tokenhub-transcriptions", Purpose: "transcription", BaseURL: "https://tokenhub.tencentmaas.com", Discovery: "DiscoveryOpenAIModels", DiscoveryAuthMode: "bearer", DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "tokenhub-speech", Purpose: "speech", BaseURL: "https://tokenhub.tencentmaas.com", Discovery: "DiscoveryOpenAIModels", DiscoveryAuthMode: "bearer", DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + }, + }, + { + Key: "globalApi", + APIConfigs: []APIConfig{ + {APIType: "openai-completions", Purpose: "text", BaseURL: "https://tokenhub-intl.tencentmaas.com/v1", Route: "/v1", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/v1", DiscoveryAuthMode: "bearer", DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "openai-responses", Purpose: "text", BaseURL: "https://tokenhub-intl.tencentmaas.com/v1", Route: "/v1", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/v1", DiscoveryAuthMode: "bearer", DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "anthropic-messages", Purpose: "text", BaseURL: "https://tokenhub-intl.tencentmaas.com", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/v1", DiscoveryAuthMode: "bearer", DiscoverModels: true, DefaultAuthMode: "x-api-key", AuthModes: []string{"x-api-key"}}, + {APIType: "openai-embeddings", Purpose: "embedding", BaseURL: "https://tokenhub-intl.tencentmaas.com/v1", Route: "/v1", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/v1", DiscoveryAuthMode: "bearer", DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + }, + }, + }, + }, + "qianfan": { + Key: "qianfan", + DisplayName: "百度千帆", + Sort: 90, + DefaultAPIType: "openai-completions", + AccountTypes: []AccountTypePreset{ + { + Key: "codingPlan", + APIConfigs: []APIConfig{ + {APIType: "openai-completions", Purpose: "text", BaseURL: "https://qianfan.baidubce.com/v2/coding", Route: "/v2/coding", Discovery: "DiscoveryNone", DiscoveryRoute: "/v2/coding", DiscoveryAuthMode: "bearer", DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "anthropic-messages", Purpose: "text", BaseURL: "https://qianfan.baidubce.com/anthropic/coding", Route: "/anthropic/coding", Discovery: "DiscoveryNone", DiscoveryRoute: "/v2/coding", DiscoveryAuthMode: "bearer", DefaultAuthMode: "x-api-key", AuthModes: []string{"x-api-key"}}, + }, + }, + { + Key: "tokenPlan", + APIConfigs: []APIConfig{ + {APIType: "openai-completions", Purpose: "text", BaseURL: "https://qianfan.baidubce.com/v2", Route: "/v2", Discovery: "DiscoveryNone", DiscoveryRoute: "/v2", DiscoveryAuthMode: "bearer", DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "anthropic-messages", Purpose: "text", BaseURL: "https://qianfan.baidubce.com/anthropic", Route: "/anthropic", Discovery: "DiscoveryNone", DiscoveryRoute: "/v2", DiscoveryAuthMode: "bearer", DefaultAuthMode: "x-api-key", AuthModes: []string{"x-api-key"}}, + }, + }, + { + Key: "payAsYouGo", + APIConfigs: []APIConfig{ + {APIType: "openai-completions", Purpose: "text", BaseURL: "https://qianfan.baidubce.com/v2", Route: "/v2", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/v2", DiscoveryAuthMode: "bearer", DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "openai-responses", Purpose: "text", BaseURL: "https://qianfan.baidubce.com/v2", Route: "/v2", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/v2", DiscoveryAuthMode: "bearer", DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "anthropic-messages", Purpose: "text", BaseURL: "https://qianfan.baidubce.com/anthropic", Route: "/anthropic", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/v2", DiscoveryAuthMode: "bearer", DiscoverModels: true, DefaultAuthMode: "x-api-key", AuthModes: []string{"x-api-key"}}, + {APIType: "openai-images", Purpose: "image", BaseURL: "https://qianfan.baidubce.com/v2", Route: "/v2", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/v2", DiscoveryAuthMode: "bearer", DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "openai-embeddings", Purpose: "embedding", BaseURL: "https://qianfan.baidubce.com/v2", Route: "/v2", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/v2", DiscoveryAuthMode: "bearer", DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "rerank", Purpose: "rerank", BaseURL: "https://qianfan.baidubce.com/v2", Route: "/v2", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/v2", DiscoveryAuthMode: "bearer", DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + }, + }, + }, + }, + "siliconflow": { + Key: "siliconflow", + DisplayName: "SiliconFlow", + Sort: 100, + DefaultAPIType: "openai-completions", + AccountTypes: []AccountTypePreset{ + { + Key: "default", + APIConfigs: []APIConfig{ + {APIType: "openai-completions", Purpose: "text", BaseURL: "https://api.siliconflow.cn/v1", Route: "/v1", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/v1", DiscoveryAuthMode: "bearer", DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "anthropic-messages", Purpose: "text", BaseURL: "https://api.siliconflow.cn", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/v1", DiscoveryAuthMode: "bearer", DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "siliconflow-images", Purpose: "image", BaseURL: "https://api.siliconflow.cn/v1", Route: "/v1", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/v1", DiscoveryAuthMode: "bearer", DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "openai-embeddings", Purpose: "embedding", BaseURL: "https://api.siliconflow.cn/v1", Route: "/v1", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/v1", DiscoveryAuthMode: "bearer", DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "rerank", Purpose: "rerank", BaseURL: "https://api.siliconflow.cn/v1", Route: "/v1", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/v1", DiscoveryAuthMode: "bearer", DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "openai-transcriptions", Purpose: "transcription", BaseURL: "https://api.siliconflow.cn/v1", Route: "/v1", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/v1", DiscoveryAuthMode: "bearer", DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "openai-speech", Purpose: "speech", BaseURL: "https://api.siliconflow.cn/v1", Route: "/v1", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/v1", DiscoveryAuthMode: "bearer", DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + }, + }, + }, + }, + "opencode": { + Key: "opencode", + DisplayName: "OpenCode", + Sort: 160, + DefaultAPIType: "openai-completions", + AccountTypes: []AccountTypePreset{ + { + Key: "go", + APIConfigs: []APIConfig{ + {APIType: "openai-completions", Purpose: "text", BaseURL: "https://opencode.ai/zen/go/v1", Route: "/zen/go/v1", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/zen/go/v1", DiscoveryAuthMode: "bearer", DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "openai-responses", Purpose: "text", BaseURL: "https://opencode.ai/zen/go/v1", Route: "/zen/go/v1", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/zen/go/v1", DiscoveryAuthMode: "bearer", DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "anthropic-messages", Purpose: "text", BaseURL: "https://opencode.ai/zen/go", Route: "/zen/go", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/zen/go/v1", DiscoveryAuthMode: "bearer", DiscoverModels: true, DefaultAuthMode: "x-api-key", AuthModes: []string{"x-api-key"}}, + }, + }, + { + Key: "zen", + APIConfigs: []APIConfig{ + {APIType: "openai-completions", Purpose: "text", BaseURL: "https://opencode.ai/zen/v1", Route: "/zen/v1", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/zen/v1", DiscoveryAuthMode: "bearer", DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "openai-responses", Purpose: "text", BaseURL: "https://opencode.ai/zen/v1", Route: "/zen/v1", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/zen/v1", DiscoveryAuthMode: "bearer", DiscoverModels: true, DefaultAuthMode: "bearer", AuthModes: []string{"bearer"}}, + {APIType: "anthropic-messages", Purpose: "text", BaseURL: "https://opencode.ai/zen", Route: "/zen", Discovery: "DiscoveryOpenAIModels", DiscoveryRoute: "/zen/v1", DiscoveryAuthMode: "bearer", DiscoverModels: true, DefaultAuthMode: "x-api-key", AuthModes: []string{"x-api-key"}}, }, }, }, }, -} - -func editableAPIConfigs(discoverModels bool, apiTypes ...string) []APIConfig { - configs := make([]APIConfig, 0, len(apiTypes)) - for _, apiType := range apiTypes { - if apiType == "anthropic-messages" { - config := anthropicAPIConfig("", AuthModeXAPIKey, AuthModeBearer) - config.EditableBaseURL = true - configs = append(configs, config) - continue - } - configs = append(configs, APIConfig{ - APIType: apiType, - EditableBaseURL: true, - DiscoverModels: discoverModels && (apiType == "openai-completions" || apiType == "openai-responses"), - }) - } - return configs -} - -func anthropicAPIConfig(baseURL, defaultAuthMode string, additionalAuthModes ...string) APIConfig { - authModes := []string{defaultAuthMode} - for _, authMode := range additionalAuthModes { - if authMode != defaultAuthMode { - authModes = append(authModes, authMode) - } - } - return APIConfig{ - APIType: "anthropic-messages", - BaseURL: baseURL, - DefaultAuthMode: defaultAuthMode, - AuthModes: authModes, - } } func Get(key string) (Meta, bool) { @@ -269,18 +626,18 @@ func Get(key string) (Meta, bool) { if !ok { return Meta{}, false } - return cloneMeta(meta), true + return meta, true } func All() map[string]Meta { result := make(map[string]Meta, len(catalog)) for key, meta := range catalog { - result[key] = cloneMeta(meta) + result[key] = meta } return result } -func FindAPIConfig(key, apiType string) (APIConfig, bool) { +func FindAPIConfig(key, apiType string, accountType ...string) (APIConfig, bool) { meta, ok := catalog[key] if !ok { return APIConfig{}, false @@ -289,42 +646,27 @@ func FindAPIConfig(key, apiType string) (APIConfig, bool) { if target == "" { target = meta.DefaultAPIType } - for _, config := range meta.APIConfigs { - if config.APIType == target { - config.AuthModes = append([]string(nil), config.AuthModes...) - config.Models = append([]Model(nil), config.Models...) - return config, true + presets := meta.AccountTypes + if len(accountType) > 0 { + preset, ok := FindAccountType(key, accountType[0]) + if !ok { + return APIConfig{}, false + } + presets = []AccountTypePreset{preset} + } + for _, preset := range presets { + for _, config := range preset.APIConfigs { + if config.APIType == target { + config.AuthModes = append([]string(nil), config.AuthModes...) + return config, true + } } } return APIConfig{}, false } -func DefaultModels(key, apiType string) []Model { - meta, ok := catalog[key] - if !ok { - return nil - } - target := strings.TrimSpace(apiType) - if target == "" { - target = meta.DefaultAPIType - } - for _, config := range meta.APIConfigs { - if config.APIType != target { - continue - } - if len(config.Models) > 0 { - return append([]Model(nil), config.Models...) - } - if IsImageAPIType(config.APIType) || IsEmbeddingAPIType(config.APIType) { - return nil - } - break - } - return append([]Model(nil), meta.Models...) -} - -func ResolveAuthMode(provider, apiType, requested string) (string, error) { - config, ok := FindAPIConfig(provider, apiType) +func ResolveAuthMode(provider, apiType, requested string, accountType ...string) (string, error) { + config, ok := FindAPIConfig(provider, apiType, accountType...) if !ok { return "", fmt.Errorf("provider %s does not support api type %s", provider, apiType) } @@ -359,8 +701,8 @@ func DefaultAPIType(key string) string { return meta.DefaultAPIType } -func ResolveBaseURL(key, apiType, requested string) (string, error) { - config, ok := FindAPIConfig(key, apiType) +func ResolveBaseURL(key, apiType, requested string, accountType ...string) (string, error) { + config, ok := FindAPIConfig(key, apiType, accountType...) if !ok { return "", fmt.Errorf("provider %s does not support api type %s", key, apiType) } @@ -417,7 +759,7 @@ func IsEmbeddingAPIType(apiType string) bool { func IsImageAPIType(apiType string) bool { switch apiType { - case "openai-images", "dashscope-images", "minimax-images", "openrouter-images": + case "openai-images", "dashscope-images", "minimax-images", "openrouter-images", "tokenhub-images", "siliconflow-images": return true default: return false @@ -481,15 +823,3 @@ var legacyModelPrefixes = map[string][]string{ "gemini": {"google", "gemini"}, "moonshot": {"moonshot"}, } - -func cloneMeta(meta Meta) Meta { - clone := meta - clone.APIConfigs = make([]APIConfig, len(meta.APIConfigs)) - for index, config := range meta.APIConfigs { - clone.APIConfigs[index] = config - clone.APIConfigs[index].AuthModes = append([]string(nil), config.AuthModes...) - clone.APIConfigs[index].Models = append([]Model(nil), config.Models...) - } - clone.Models = append([]Model(nil), meta.Models...) - return clone -} diff --git a/agent/app/provider/discover.go b/agent/app/provider/discover.go index 96bb539c2..5220b83a2 100644 --- a/agent/app/provider/discover.go +++ b/agent/app/provider/discover.go @@ -1,9 +1,11 @@ package provider import ( + "context" "encoding/json" "fmt" "net/http" + "net/url" "strconv" "strings" @@ -65,17 +67,26 @@ func DiscoverModels(baseURL, apiKey string) ([]string, error) { func buildModelDiscoveryURL(baseURL string) string { base := strings.TrimRight(strings.TrimSpace(baseURL), "/") - for _, apiType := range []string{"openai-completions", "openai-responses", "anthropic-messages"} { - base = normalizeEndpointPath(apiType, base) - } - switch { - case strings.HasSuffix(base, "/models"): + parsed, err := url.Parse(base) + if err != nil { return base - case hasAPIVersionSuffix(base): - return base + "/models" - default: - return base + "/v1/models" } + path := strings.TrimRight(parsed.Path, "/") + for _, suffix := range []string{"/chat/completions", "/responses", "/messages", "/images/generations", "/embeddings"} { + if strings.HasSuffix(strings.ToLower(path), suffix) { + path = path[:len(path)-len(suffix)] + break + } + } + if !strings.HasSuffix(path, "/models") { + if !hasAPIVersionSuffix(path) { + path += "/v1" + } + path += "/models" + } + parsed.Path = path + parsed.RawPath = "" + return parsed.String() } func hasAPIVersionSuffix(value string) bool { @@ -86,3 +97,161 @@ func hasAPIVersionSuffix(value string) bool { _, err := strconv.Atoi(segment[1:]) return err == nil } + +func DiscoverProtocolModels(provider string, config APIConfig, baseURL, apiKey, authMode string) ([]string, error) { + if baseURL == "" { + baseURL = config.BaseURL + } + if config.DiscoveryAuthMode != "" && provider != "custom" && provider != "vllm" { + authMode = config.DiscoveryAuthMode + } + if config.Route != config.DiscoveryRoute && provider != "custom" && provider != "vllm" && config.Discovery != "DiscoveryOllamaModels" { + baseURL = strings.TrimSuffix(strings.TrimRight(baseURL, "/"), config.Route) + config.DiscoveryRoute + } + endpoint := buildModelDiscoveryURL(baseURL) + strategy := config.Discovery + root, err := url.Parse(baseURL) + if err != nil { + return nil, aihttp.ErrTarget + } + root.Path, root.RawQuery = "", "" + switch strategy { + case "DiscoveryGeminiModels": + endpoint = root.String() + "/v1beta/models?pageSize=100" + authMode = "x-goog-api-key" + case "DiscoveryAnthropicModels": + endpoint = strings.TrimRight(baseURL, "/") + "/v1/models?limit=100" + case "DiscoveryOllamaModels": + endpoint = strings.TrimSuffix(strings.TrimRight(baseURL, "/"), "/v1") + "/api/tags" + case "DiscoveryDashScopeModels": + if config.Purpose == "text" { + endpoint = root.String() + "/compatible-mode/v1/models" + strategy = "DiscoveryOpenAIModels" + } else { + endpoint = root.String() + "/api/v1/models?page_size=100&page_no=1" + } + } + if provider == "deepseek" { + endpoint = root.String() + "/models" + } + if provider == "minimax" { + endpoint = root.String() + "/v1/models" + authMode = "bearer" + } + if provider == "openrouter" { + endpoint = root.String() + "/api/v1/models?output_modalities=" + url.QueryEscape(config.Purpose) + if config.Purpose == "embedding" { + endpoint = root.String() + "/api/v1/models?output_modalities=embeddings" + } + } + result := []string{} + seen := map[string]bool{} + seenPages := map[string]bool{} + ctx, cancel := context.WithTimeout(context.Background(), defaultVerifyTimeout) + defer cancel() + for page := 0; page < 50; page++ { + if seenPages[endpoint] { + return nil, aihttp.ErrResponse + } + seenPages[endpoint] = true + req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint, nil) + if err != nil { + return nil, aihttp.ErrTarget + } + if apiKey != "" { + switch authMode { + case "x-api-key": + req.Header.Set("x-api-key", apiKey) + case "x-goog-api-key": + req.Header.Set("x-goog-api-key", apiKey) + default: + req.Header.Set("Authorization", "Bearer "+apiKey) + } + } + req.Header.Set("anthropic-version", "2023-06-01") + response, err := aihttp.NewClient(defaultVerifyTimeout).Do(req) + if err != nil { + return nil, aihttp.SafeError(err, endpoint, apiKey) + } + body, readErr := aihttp.ReadResponseBody(response.Body) + response.Body.Close() + if readErr != nil { + return nil, readErr + } + if response.StatusCode != http.StatusOK { + return nil, aihttp.HTTPError(response.StatusCode, body, endpoint, apiKey) + } + var payload struct { + Data []struct { + ID string `json:"id"` + } `json:"data"` + Models []struct { + Name string `json:"name"` + Model string `json:"model"` + } `json:"models"` + HasMore bool `json:"has_more"` + LastID string `json:"last_id"` + NextPageToken string `json:"nextPageToken"` + Output struct { + Models []struct { + Model string `json:"model"` + Capabilities []string `json:"capabilities"` + } `json:"models"` + Total int `json:"total"` + Page int `json:"page_no"` + } `json:"output"` + } + if json.Unmarshal(body, &payload) != nil { + return nil, aihttp.ErrResponse + } + ids := []string{} + for _, row := range payload.Output.Models { + for _, capability := range row.Capabilities { + if map[string]string{"TG": "text", "IG": "image", "TR": "embedding", "ME": "embedding", "ASR": "transcription", "TTS": "speech"}[capability] == config.Purpose { + ids = append(ids, row.Model) + break + } + } + } + for _, row := range payload.Data { + ids = append(ids, row.ID) + } + for _, row := range payload.Models { + id := row.Name + if row.Model != "" { + id = row.Model + } + ids = append(ids, strings.TrimPrefix(id, "models/")) + } + for _, id := range ids { + id = strings.TrimSpace(id) + if id == "" || len(id) > 512 { + continue + } + if !seen[id] { + result = append(result, id) + seen[id] = true + } + if len(result) > aihttp.MaxDiscoveredModels { + return nil, fmt.Errorf("model discovery exceeded the model limit") + } + } + next, _ := url.Parse(endpoint) + query := next.Query() + if strategy == "DiscoveryAnthropicModels" && payload.HasMore && payload.LastID != "" { + query.Set("after_id", payload.LastID) + } else if strategy == "DiscoveryGeminiModels" && payload.NextPageToken != "" { + query.Set("pageToken", payload.NextPageToken) + } else if strategy == "DiscoveryDashScopeModels" && payload.Output.Page*100 < payload.Output.Total { + if payload.Output.Page < 1 || len(payload.Output.Models) == 0 { + return nil, aihttp.ErrResponse + } + query.Set("page_no", strconv.Itoa(payload.Output.Page+1)) + } else { + return result, nil + } + next.RawQuery = query.Encode() + endpoint = next.String() + } + return nil, fmt.Errorf("model discovery exceeded the page limit") +} diff --git a/agent/app/provider/endpoint.go b/agent/app/provider/endpoint.go new file mode 100644 index 000000000..721a088f2 --- /dev/null +++ b/agent/app/provider/endpoint.go @@ -0,0 +1,52 @@ +package provider + +import ( + "net/url" + "strings" +) + +func BuildTextRequestURL(apiType, baseURL, model string) string { + baseURL = strings.TrimRight(strings.TrimSpace(baseURL), "/") + parsed, err := url.Parse(baseURL) + if err != nil { + return baseURL + } + path := strings.TrimRight(parsed.Path, "/") + var endpoint string + switch apiType { + case "openai-completions": + endpoint = "/chat/completions" + case "openai-responses": + endpoint = "/responses" + case "anthropic-messages": + endpoint = "/messages" + case "gemini-generate-content": + if strings.Contains(path, "/models/") && strings.HasSuffix(path, ":generateContent") { + return parsed.String() + } + if !strings.HasSuffix(path, "/v1beta") { + path += "/v1beta" + } + parsed.Path = path + "/models/" + strings.TrimSpace(model) + ":generateContent" + parsed.RawPath = "" + return parsed.String() + default: + return baseURL + } + if strings.HasSuffix(path, endpoint) { + return parsed.String() + } + versioned := false + for _, segment := range strings.Split(path, "/") { + if hasAPIVersionSuffix(segment) || segment == "v1beta" { + versioned = true + break + } + } + if (apiType == "anthropic-messages" && !strings.HasSuffix(path, "/v1")) || (apiType != "anthropic-messages" && !versioned) { + path += "/v1" + } + parsed.Path = path + endpoint + parsed.RawPath = "" + return parsed.String() +} diff --git a/agent/app/provider/minimax_test.go b/agent/app/provider/minimax_test.go deleted file mode 100644 index b0efe792f..000000000 --- a/agent/app/provider/minimax_test.go +++ /dev/null @@ -1,100 +0,0 @@ -package provider - -import ( - "encoding/json" - "net/http" - "net/http/httptest" - "reflect" - "strings" - "testing" -) - -func TestMiniMaxCatalog(t *testing.T) { - meta, ok := Get("minimax") - if !ok || !reflect.DeepEqual(meta.Models, []Model{{ID: "MiniMax-M3.1-Flash", Name: "MiniMax M3.1 Flash"}, {ID: "MiniMax-M3", Name: "MiniMax M3"}}) { - t.Fatalf("unexpected MiniMax models: %+v", meta.Models) - } - if meta.DefaultAPIType != "anthropic-messages" { - t.Fatalf("changed default protocol: %s", meta.DefaultAPIType) - } - for _, provider := range All() { - for _, model := range provider.Models { - if strings.Contains(strings.ToLower(model.ID), "minimax") && model.ID != "MiniMax-M3.1-Flash" && model.ID != "MiniMax-M3" { - t.Errorf("legacy suggestion in %s: %s", provider.Key, model.ID) - } - } - } -} - -func TestMiniMaxVerificationRequests(t *testing.T) { - for _, region := range []string{"https://api.minimaxi.com", "https://api.minimax.io"} { - for _, protocol := range []string{"anthropic-messages", "openai-completions"} { - for _, auth := range []string{AuthModeXAPIKey, AuthModeBearer} { - for _, model := range []string{"MiniMax-M3.1-Flash", "MiniMax-M3", "MiniMax-M2.7", "MiniMax-M2.7-highspeed", "custom-model"} { - t.Run(region+"/"+protocol+"/"+auth+"/"+model, func(t *testing.T) { - base, endpoint := region+"/v1", "/chat/completions" - if protocol == "anthropic-messages" { - base, endpoint = region+"/anthropic", "/v1/messages" - } - built := BuildVerifyRequest("minimax", protocol, auth, base, "test-key", model) - if built.URL != base+endpoint { - t.Fatalf("URL = %s", built.URL) - } - var captured map[string]interface{} - server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - if r.Method != http.MethodPost || r.URL.Path != strings.TrimPrefix(base, region)+endpoint { - t.Errorf("unexpected request: %s %s", r.Method, r.URL.Path) - } - if protocol == "anthropic-messages" && auth == AuthModeXAPIKey { - if r.Header.Get("x-api-key") != "test-key" || r.Header.Get("Authorization") != "" { - t.Error("incorrect API key authentication") - } - } else if r.Header.Get("Authorization") != "Bearer test-key" { - t.Error("incorrect bearer authentication") - } - if err := json.NewDecoder(r.Body).Decode(&captured); err != nil { - t.Error(err) - } - w.WriteHeader(http.StatusOK) - })) - defer server.Close() - if err := VerifyAccount("minimax", protocol, auth, server.URL+strings.TrimPrefix(base, region), "test-key", model); err != nil { - t.Fatal(err) - } - if captured["model"] != model || captured["stream"] != false || captured["max_tokens"] != float64(defaultVerifyMaxTokens) { - t.Fatalf("unexpected serialized body: %#v", captured) - } - if model == "MiniMax-M3.1-Flash" { - if protocol == "anthropic-messages" { - if !reflect.DeepEqual(captured["thinking"], map[string]interface{}{"type": "adaptive"}) || !reflect.DeepEqual(captured["output_config"], map[string]interface{}{"effort": "max"}) || captured["reasoning_effort"] != nil { - t.Fatalf("invalid Anthropic Flash reasoning: %#v", captured) - } - } else if captured["reasoning_effort"] != "max" || captured["thinking"] != nil || captured["output_config"] != nil { - t.Fatalf("invalid OpenAI Flash reasoning: %#v", captured) - } - } else if captured["reasoning_effort"] != nil || captured["thinking"] != nil || captured["output_config"] != nil { - t.Fatalf("changed legacy/custom reasoning: %#v", captured) - } - }) - } - } - } - } -} - -func TestMiniMaxExplicitGatewayAndCustomModels(t *testing.T) { - for _, provider := range []string{"bailian-coding-plan", "custom", "openrouter"} { - for _, protocol := range []string{"openai-completions", "anthropic-messages"} { - for _, model := range []string{"MiniMax-M2.5", "MiniMax-M3.1-Flash", "my-custom-model"} { - request := BuildVerifyRequest(provider, protocol, AuthModeBearer, "https://example.test/v1", "test-key", model) - var body map[string]interface{} - if err := json.Unmarshal(request.Body, &body); err != nil { - t.Fatal(err) - } - if body["model"] != model || body["reasoning_effort"] != nil || body["output_config"] != nil || body["thinking"] != nil { - t.Fatalf("changed explicit %s request: %#v", provider, body) - } - } - } - } -} diff --git a/agent/app/provider/openclaw.go b/agent/app/provider/openclaw.go index bea657fd0..33c4289aa 100644 --- a/agent/app/provider/openclaw.go +++ b/agent/app/provider/openclaw.go @@ -23,7 +23,7 @@ func BuildOpenClawProviderPatch(provider, modelName, apiType, authMode, baseURL, if _, ok := FindAPIConfig(provider, resolvedAPIType); !ok { resolvedAPIType = DefaultAPIType(provider) } - if IsImageAPIType(resolvedAPIType) || IsEmbeddingAPIType(resolvedAPIType) { + if Purpose(resolvedAPIType) != "text" { return nil, fmt.Errorf("api type %s does not support text generation", resolvedAPIType) } resolvedAuthMode, err := ResolveAuthMode(provider, resolvedAPIType, authMode) @@ -37,12 +37,12 @@ func BuildOpenClawProviderPatch(provider, modelName, apiType, authMode, baseURL, switch provider { case "gemini": providerKey = "google" - resolvedAPIType = "google-generative-ai" + if resolvedAPIType == "gemini-generate-content" { + resolvedAPIType = "google-generative-ai" + } usesBearer = false case "moonshot", "kimi": providerKey = "moonshot" - resolvedAPIType = "openai-completions" - usesBearer = false case "ollama", "llmman": apiKey = provider usesBearer = false diff --git a/agent/app/provider/verify.go b/agent/app/provider/verify.go index b954aadf2..30ab2d956 100644 --- a/agent/app/provider/verify.go +++ b/agent/app/provider/verify.go @@ -3,6 +3,7 @@ package provider import ( "bytes" "encoding/json" + "fmt" "net/http" "strings" "time" @@ -24,6 +25,14 @@ const ( ) func VerifyAccount(provider, apiType, authMode, baseURL, apiKey, model string) error { + if Purpose(apiType) == "speech" || Purpose(apiType) == "transcription" { + return fmt.Errorf("%s verification requires audio input; disable automatic verification and test with an audio client", apiType) + } + switch apiType { + case "openai-completions", "openai-responses", "anthropic-messages", "gemini-generate-content", "openai-embeddings", "openai-images", "dashscope-images", "minimax-images", "openrouter-images", "tokenhub-images", "siliconflow-images", "rerank": + default: + return fmt.Errorf("automatic verification is not supported for %s", apiType) + } req := BuildVerifyRequest(provider, apiType, authMode, baseURL, apiKey, model) httpReq, err := http.NewRequest(req.Method, req.URL, bytes.NewReader(req.Body)) if err != nil { @@ -56,8 +65,8 @@ func BuildVerifyRequest(provider, apiType, authMode, baseURL, apiKey, model stri headers := map[string]string{"Content-Type": "application/json"} request := VerifyRequest{Method: http.MethodPost, Headers: headers} - if provider == "gemini" { - request.URL = baseURL + "/v1beta/models/" + strings.TrimSpace(model) + ":generateContent" + if apiType == "gemini-generate-content" { + request.URL = BuildTextRequestURL(apiType, baseURL, model) headers["x-goog-api-key"] = apiKey request.Body = mustJSON(map[string]interface{}{ "contents": []map[string]interface{}{{"parts": []map[string]string{{"text": "test"}}}}, @@ -66,6 +75,26 @@ func BuildVerifyRequest(provider, apiType, authMode, baseURL, apiKey, model stri } switch apiType { + case "rerank": + request.URL = strings.TrimRight(baseURL, "/") + "/rerank" + headers["Authorization"] = "Bearer " + apiKey + request.Body = mustJSON(map[string]interface{}{"model": model, "query": "test", "documents": []string{"test"}}) + if provider == "bailian" { + if model == "qwen3-rerank" { + request.URL = baseURL + "/compatible-api/v1/reranks" + } else { + request.URL = baseURL + "/api/v1/services/rerank/text-rerank/text-rerank" + request.Body = mustJSON(map[string]interface{}{"model": model, "input": map[string]interface{}{"query": "test", "documents": []string{"test"}}}) + } + } + case "tokenhub-images": + request.URL = imageVerifyURL(provider, baseURL, "/v1/wand/hunyuan-image/v3-generation") + headers["Authorization"] = "Bearer " + apiKey + request.Body = mustJSON(map[string]interface{}{"model": model, "prompt": "test"}) + case "siliconflow-images": + request.URL = imageVerifyURL(provider, baseURL, "/images/generations") + headers["Authorization"] = "Bearer " + apiKey + request.Body = mustJSON(map[string]interface{}{"model": model, "prompt": "test", "image_size": "1024x1024", "batch_size": 1}) case "openai-embeddings": request.URL = embeddingVerifyURL(baseURL) headers["Authorization"] = "Bearer " + apiKey @@ -93,7 +122,7 @@ func BuildVerifyRequest(provider, apiType, authMode, baseURL, apiKey, model stri headers["Authorization"] = "Bearer " + apiKey request.Body = mustJSON(map[string]interface{}{"model": model, "prompt": "test", "n": 1, "response_format": "url"}) case "anthropic-messages": - request.URL = baseURL + "/v1/messages" + request.URL = BuildTextRequestURL(apiType, baseURL, model) if authMode == AuthModeBearer { headers["Authorization"] = "Bearer " + apiKey } else { @@ -110,11 +139,11 @@ func BuildVerifyRequest(provider, apiType, authMode, baseURL, apiKey, model stri } request.Body = mustJSON(body) case "openai-responses": - request.URL = baseURL + "/responses" + request.URL = BuildTextRequestURL(apiType, baseURL, model) headers["Authorization"] = "Bearer " + apiKey request.Body = mustJSON(map[string]interface{}{"model": model, "input": "test", "max_output_tokens": defaultVerifyMaxTokens, "stream": false}) default: - request.URL = baseURL + "/chat/completions" + request.URL = BuildTextRequestURL(apiType, baseURL, model) if (provider != "ollama" && provider != "llmman") || strings.TrimSpace(apiKey) != "" { headers["Authorization"] = "Bearer " + apiKey } @@ -137,7 +166,7 @@ func embeddingVerifyURL(baseURL string) string { if strings.HasSuffix(lowerBaseURL, "/embeddings") { return baseURL } - if strings.HasSuffix(lowerBaseURL, "/v1") { + if hasAPIVersionSuffix(lowerBaseURL) { return baseURL + "/embeddings" } return baseURL + "/v1/embeddings" diff --git a/agent/app/repo/agent_account.go b/agent/app/repo/agent_account.go index a2e413237..5b1950efa 100644 --- a/agent/app/repo/agent_account.go +++ b/agent/app/repo/agent_account.go @@ -21,7 +21,7 @@ type IAgentAccountRepo interface { DeleteByID(id uint) error List(opts ...DBOption) ([]model.AgentAccount, error) Count() (int64, error) - CountTextByProviders(providers []string) (map[string]int64, error) + CountTextByProviders(providers []string, opts ...DBOption) (map[string]int64, error) SaveWithModels(account *model.AgentAccount, models []model.AgentAccountModel) error } @@ -102,7 +102,7 @@ func (a AgentAccountRepo) Count() (int64, error) { return count, err } -func (a AgentAccountRepo) CountTextByProviders(providers []string) (map[string]int64, error) { +func (a AgentAccountRepo) CountTextByProviders(providers []string, opts ...DBOption) (map[string]int64, error) { normalizedProviders := normalizeProviders(providers) counts := make(map[string]int64, len(normalizedProviders)) for _, provider := range normalizedProviders { @@ -117,7 +117,7 @@ func (a AgentAccountRepo) CountTextByProviders(providers []string) (map[string]i Count int64 } var rows []providerCount - if err := getDb(). + if err := getDb(opts...). Model(&model.AgentAccount{}). Select("provider, COUNT(*) as count"). Where("provider IN ?", normalizedProviders). diff --git a/agent/app/repo/agent_account_model.go b/agent/app/repo/agent_account_model.go index 67b54160b..967e5a0e9 100644 --- a/agent/app/repo/agent_account_model.go +++ b/agent/app/repo/agent_account_model.go @@ -12,7 +12,6 @@ type IAgentAccountModelRepo interface { GetFirst(opts ...DBOption) (*model.AgentAccountModel, error) Create(item *model.AgentAccountModel) error Save(item *model.AgentAccountModel) error - SaveWithAccount(item *model.AgentAccountModel, account *model.AgentAccount) error DeleteByID(id uint) error DeleteWithAccount(id uint, account *model.AgentAccount) error Delete(opts ...DBOption) error @@ -46,15 +45,6 @@ func (a AgentAccountModelRepo) Save(item *model.AgentAccountModel) error { return getDb().Save(item).Error } -func (a AgentAccountModelRepo) SaveWithAccount(item *model.AgentAccountModel, account *model.AgentAccount) error { - return getDb().Transaction(func(tx *gorm.DB) error { - if err := tx.Save(item).Error; err != nil { - return err - } - return tx.Save(account).Error - }) -} - func (a AgentAccountModelRepo) DeleteByID(id uint) error { return getDb().Delete(&model.AgentAccountModel{}, id).Error } diff --git a/agent/app/repo/common.go b/agent/app/repo/common.go index e9fa4c712..ae1bf8d20 100644 --- a/agent/app/repo/common.go +++ b/agent/app/repo/common.go @@ -108,7 +108,16 @@ func WithByAPIType(apiType string) DBOption { func WithTextAPIType() DBOption { return func(g *gorm.DB) *gorm.DB { - return g.Where("api_type NOT LIKE ? AND api_type <> ?", "%-images", "openai-embeddings") + return g.Where("api_type IN ?", []string{"", "openai-completions", "openai-responses", "anthropic-messages", "gemini-generate-content"}) + } +} + +func WithExcludeCodingPlanProviders(providers []string) DBOption { + return func(g *gorm.DB) *gorm.DB { + if len(providers) == 0 { + return g + } + return g.Where("(provider NOT IN ? OR account_type IS NULL OR account_type <> ?)", providers, "codingPlan") } } diff --git a/agent/app/service/agents.go b/agent/app/service/agents.go index 8ae533083..e2070a325 100644 --- a/agent/app/service/agents.go +++ b/agent/app/service/agents.go @@ -713,6 +713,7 @@ func (a AgentService) ensureBatchInstallAccount(req dto.AgentBatchInstallReq) (u } account.MasterAccountID = req.MasterAccountID account.Provider = snapshot.Provider + account.AccountType = snapshot.AccountType account.Name = snapshot.Name account.APIKey = snapshot.APIKey account.RememberAPIKey = snapshot.RememberAPIKey @@ -1000,32 +1001,19 @@ func (a AgentService) GetProviders() ([]dto.ProviderInfo, error) { definitions := providercatalog.All() providers := make([]dto.ProviderInfo, 0, len(definitions)) for key, def := range definitions { - models := make([]dto.ProviderModelInfo, 0, len(def.Models)) - for _, item := range def.Models { - models = append(models, dto.ProviderModelInfo{ - ID: item.ID, - Name: item.Name, - }) - } - apiTypes := make([]dto.ProviderAPIInfo, 0, len(def.APIConfigs)) - for _, item := range def.APIConfigs { - apiModels := make([]dto.ProviderModelInfo, 0, len(item.Models)) - for _, model := range item.Models { - apiModels = append(apiModels, dto.ProviderModelInfo{ - ID: model.ID, - Name: model.Name, + accountTypes := make([]dto.ProviderAccountTypeInfo, 0, len(def.AccountTypes)) + for _, preset := range def.AccountTypes { + item := dto.ProviderAccountTypeInfo{Key: preset.Key, APITypes: []dto.ProviderAPIInfo{}} + for _, config := range preset.APIConfigs { + item.APITypes = append(item.APITypes, dto.ProviderAPIInfo{ + APIType: config.APIType, BaseURL: config.BaseURL, EditableBaseURL: config.EditableBaseURL, + SupportsModelDiscovery: config.DiscoverModels, DefaultAuthMode: config.DefaultAuthMode, + AuthModes: config.AuthModes, Models: []dto.ProviderModelInfo{}, }) } - apiTypes = append(apiTypes, dto.ProviderAPIInfo{ - APIType: item.APIType, - BaseURL: item.BaseURL, - EditableBaseURL: item.EditableBaseURL, - SupportsModelDiscovery: item.DiscoverModels, - DefaultAuthMode: item.DefaultAuthMode, - AuthModes: item.AuthModes, - Models: apiModels, - }) + accountTypes = append(accountTypes, item) } + apiTypes := accountTypes[0].APITypes baseURL, _ := providercatalog.DefaultBaseURL(key) providers = append(providers, dto.ProviderInfo{ Sort: def.Sort, @@ -1034,7 +1022,8 @@ func (a AgentService) GetProviders() ([]dto.ProviderInfo, error) { BaseURL: baseURL, DefaultAPIType: def.DefaultAPIType, APITypes: apiTypes, - Models: models, + Models: []dto.ProviderModelInfo{}, + AccountTypes: accountTypes, }) } sort.Slice(providers, func(i, j int) bool { @@ -1045,6 +1034,11 @@ func (a AgentService) GetProviders() ([]dto.ProviderInfo, error) { func (a AgentService) CreateAccount(req dto.AgentAccountCreateReq) error { provider := req.Provider + preset, ok := providercatalog.FindAccountType(provider, req.AccountType) + if !ok { + return buserr.WithDetail("ErrInvalidParams", "unsupported provider type", nil) + } + req.AccountType = preset.Key if err := ensureAgentAccountNameAvailable(provider, req.Name, 0); err != nil { return err } @@ -1057,7 +1051,7 @@ func (a AgentService) CreateAccount(req dto.AgentAccountCreateReq) error { return err } validateAvailability := req.ValidateAvailability == nil || *req.ValidateAvailability - resolvedInput, err := resolveAgentAccountInput(provider, req.APIType, req.AuthMode, req.APIKey, req.BaseURL, verifyModel, validateAvailability, false) + resolvedInput, err := resolveAgentAccountInput(provider, req.APIType, req.AuthMode, req.APIKey, req.BaseURL, verifyModel, validateAvailability, false, req.AccountType) if err != nil { return err } @@ -1068,6 +1062,7 @@ func (a AgentService) CreateAccount(req dto.AgentAccountCreateReq) error { } account := &model.AgentAccount{ Provider: resolvedInput.Provider, + AccountType: req.AccountType, Name: req.Name, APIKey: resolvedInput.APIKey, RememberAPIKey: req.RememberAPIKey, @@ -1106,6 +1101,9 @@ func (a AgentService) UpdateAccount(req dto.AgentAccountUpdateReq) error { if req.APIType != account.APIType { return buserr.WithDetail("ErrInvalidParams", "API type cannot be changed", nil) } + if req.AccountType != "" && req.AccountType != account.AccountType { + return buserr.WithDetail("ErrInvalidParams", "account type cannot be changed", nil) + } provider := account.Provider if err := ensureAgentAccountNameAvailable(provider, req.Name, account.ID); err != nil { return err @@ -1144,10 +1142,19 @@ func (a AgentService) UpdateAccount(req dto.AgentAccountUpdateReq) error { if req.ValidateAvailability != nil { validateAvailability = *req.ValidateAvailability } - resolvedInput, err := resolveAgentAccountInput(provider, req.APIType, req.AuthMode, req.APIKey, req.BaseURL, verifyModel, false, account.AppInstallID != 0 && len(models) == 0) + resolvedInput, err := resolveAgentAccountInput(provider, req.APIType, req.AuthMode, req.APIKey, req.BaseURL, verifyModel, false, account.AppInstallID != 0 && len(models) == 0, account.AccountType) if err != nil { return err } + if provider == "ollama" && req.Models != nil { + if err := resolveUpdatedOllamaModels(resolvedInput.BaseURL, resolvedInput.APIKey, previousModels, models); err != nil { + return err + } + verifyModel, err = resolveAgentAccountVerifyModel(provider, verifyModel, models) + if err != nil { + return err + } + } previousVerifyModel := account.VerifyModel if previousVerifyModel == "" && len(previousModels) > 0 { previousVerifyModel = previousModels[0].ID @@ -1156,7 +1163,7 @@ func (a AgentService) UpdateAccount(req dto.AgentAccountUpdateReq) error { account.APIType != resolvedInput.APIType || account.AuthMode != resolvedInput.AuthMode || !sameProviderModelID(provider, previousVerifyModel, verifyModel) shouldVerify := validateAvailability && (connectionChanged || !account.ValidateAvailability) if shouldVerify { - if _, err := resolveAgentAccountInput(provider, req.APIType, req.AuthMode, req.APIKey, req.BaseURL, verifyModel, true, false); err != nil { + if _, err := resolveAgentAccountInput(provider, req.APIType, req.AuthMode, req.APIKey, req.BaseURL, verifyModel, true, false, account.AccountType); err != nil { return err } } @@ -1217,7 +1224,7 @@ func (a AgentService) UpdateAccount(req dto.AgentAccountUpdateReq) error { } func (a AgentService) PageAccounts(req dto.AgentAccountSearch) (int64, []dto.AgentAccountInfo, error) { - var opts []repo.DBOption + opts := []repo.DBOption{repo.WithExcludeCodingPlanProviders(req.ExcludeCodingPlanProviders)} if strings.TrimSpace(req.Provider) != "" { opts = append(opts, repo.WithByProvider(req.Provider)) } @@ -1261,6 +1268,7 @@ func (a AgentService) PageAccounts(req dto.AgentAccountSearch) (int64, []dto.Age appInstallID = item.AppInstallID } items = append(items, dto.AgentAccountInfo{ + AccountType: item.AccountType, AppInstallID: appInstallID, ID: item.ID, MasterAccountID: item.MasterAccountID, @@ -1307,7 +1315,7 @@ func (a AgentService) PageAccounts(req dto.AgentAccountSearch) (int64, []dto.Age } func (a AgentService) CountAccountsByProviders(req dto.AgentAccountProviderCountReq) (map[string]int64, error) { - return agentAccountRepo.CountTextByProviders(req.Providers) + return agentAccountRepo.CountTextByProviders(req.Providers, repo.WithExcludeCodingPlanProviders(req.ExcludeCodingPlanProviders)) } func (a AgentService) GetAccountModels(req dto.AgentAccountModelReq) ([]dto.AgentAccountModel, error) { @@ -1363,15 +1371,31 @@ func (a AgentService) UpdateAccountVerifyModel(req dto.AgentAccountVerifyModelUp } func (a AgentService) DiscoverAccountModels(req dto.AgentAccountModelDiscoverReq) ([]dto.AgentAccountModel, error) { - config, ok := providercatalog.FindAPIConfig(req.Provider, req.APIType) + if req.AccountID != 0 { + account, err := agentAccountRepo.GetFirst(repo.WithByID(req.AccountID)) + if err != nil { + return nil, err + } + req.Provider, req.AccountType, req.APIType = account.Provider, account.AccountType, account.APIType + req.BaseURL, req.APIKey, req.AuthMode = account.BaseURL, account.APIKey, account.AuthMode + } + config, ok := providercatalog.FindAPIConfig(req.Provider, req.APIType, req.AccountType) if !ok || !config.DiscoverModels { return nil, buserr.New("ErrAgentAccountModelsRequired") } - baseURL, err := providercatalog.ResolveBaseURL(req.Provider, req.APIType, req.BaseURL) - if err != nil { - return nil, buserr.WithErr("ErrAgentAccountUnavailable", err) + baseURL := req.BaseURL + if req.AccountID == 0 { + var err error + baseURL, err = providercatalog.ResolveBaseURL(req.Provider, req.APIType, req.BaseURL, req.AccountType) + if err != nil { + return nil, buserr.WithErr("ErrAgentAccountUnavailable", err) + } } - models, err := providercatalog.DiscoverModels(baseURL, req.APIKey) + authMode, err := providercatalog.ResolveAuthMode(req.Provider, req.APIType, req.AuthMode, req.AccountType) + if err != nil { + return nil, err + } + models, err := providercatalog.DiscoverProtocolModels(req.Provider, config, baseURL, req.APIKey, authMode) if err != nil { return nil, buserr.WithErr("ErrAgentAccountUnavailable", err) } @@ -1443,76 +1467,45 @@ func (a AgentService) UpdateAccountModel(req dto.AgentAccountModelUpdateReq) err if err != nil { return err } - record, err := agentAccountModelRepo.GetFirst(repo.WithByID(req.Model.RecordID), repo.WithByAccountID(req.AccountID)) + if account.AppInstallID != 0 { + return buserr.WithDetail("ErrInvalidParams", "local model pool is managed by the deployment", nil) + } + previousModels, err := loadAgentAccountModels(account) if err != nil { return err } - models, err := loadAgentAccountModels(account) + models, err := normalizeAgentAccountModels(account, req.Models) if err != nil { return err } - nextModel, err := normalizeAgentAccountModel(account, req.Model) - if err != nil { - return err - } - if account.Provider == "ollama" && !sameProviderModelID("ollama", record.Model, nextModel.ID) { - if account.AppInstallID != 0 { - return buserr.New("ErrInvalidParams") - } - nextModel.ID, err = resolveExistingOllamaModel(account, nextModel.ID) - if err != nil { + if account.Provider == "ollama" { + if err := resolveUpdatedOllamaModels(account.BaseURL, account.APIKey, previousModels, models); err != nil { return err } } - nextModel.RecordID = req.Model.RecordID - for _, item := range models { - if item.RecordID == req.Model.RecordID { - continue - } - if sameProviderModelID(account.Provider, item.ID, nextModel.ID) { - return buserr.New("ErrRecordExist") - } - } - nextModels := make([]dto.AgentAccountModel, 0, len(models)) - for _, item := range models { - if item.RecordID == req.Model.RecordID { - nextModels = append(nextModels, nextModel) - continue - } - nextModels = append(nextModels, item) - } - if err := ensureAccountModelsNotBound(account, nextModels); err != nil { - return err - } agentAccountMutationMu.Lock() defer agentAccountMutationMu.Unlock() - if err := ensureAgentAccountUnchanged(account, models); err != nil { + if err := ensureAgentAccountUnchanged(account, previousModels); err != nil { return err } - if err := ensureAccountModelsNotBound(account, nextModels); err != nil { + if err := ensureAccountModelsNotBound(account, models); err != nil { return err } - previousModelID := record.Model - record.Model = nextModel.ID - record.Name = nextModel.Name - verifyModel := account.VerifyModel - if verifyModel == "" && len(models) > 0 { - verifyModel = models[0].ID - } - if sameProviderModelID(account.Provider, verifyModel, previousModelID) && !sameProviderModelID(account.Provider, previousModelID, nextModel.ID) { - if account.ValidateAvailability { - account.Verified = false - account.VerifiedAt = nil - account.VerifyError = "" - } - account.VerifyModel = nextModel.ID - err = agentAccountModelRepo.SaveWithAccount(record, account) - } else { - err = agentAccountModelRepo.Save(record) - } + verifyModel, err := resolveAgentAccountVerifyModel(account.Provider, req.VerifyModel, models) if err != nil { return err } + if account.ValidateAvailability && !sameProviderModelID(account.Provider, account.VerifyModel, verifyModel) { + account.Verified, account.VerifiedAt, account.VerifyError = false, nil, "" + } + account.VerifyModel = verifyModel + rows := make([]model.AgentAccountModel, 0, len(models)) + for _, item := range models { + rows = append(rows, model.AgentAccountModel{Model: item.ID, Name: item.Name}) + } + if err := agentAccountRepo.SaveWithModels(account, rows); err != nil { + return err + } terminalai.InvalidateTerminalRuntimeCache() terminalai.InvalidateFileAIRuntimeCache() return a.syncAgentsByAccount(account) @@ -1632,7 +1625,7 @@ func (a AgentService) VerifyAccount(req dto.AgentAccountVerifyReq) error { } verifyModel, verifyErr := resolveAgentAccountVerifyModel(account.Provider, account.VerifyModel, models) if verifyErr == nil { - _, verifyErr = resolveAgentAccountInput(account.Provider, account.APIType, account.AuthMode, account.APIKey, account.BaseURL, verifyModel, true, false) + verifyErr = providercatalog.VerifyAccount(account.Provider, account.APIType, account.AuthMode, account.BaseURL, account.APIKey, verifyModel) } agentAccountMutationMu.Lock() defer agentAccountMutationMu.Unlock() diff --git a/agent/app/service/agents_hermes.go b/agent/app/service/agents_hermes.go index d17ede181..f32a109a2 100644 --- a/agent/app/service/agents_hermes.go +++ b/agent/app/service/agents_hermes.go @@ -406,7 +406,7 @@ func normalizeHermesTimezone(timezone string) string { } func resolveHermesProvider(provider, apiType string) string { - if apiType == "anthropic-messages" && (provider == "deepseek" || provider == "bailian-coding-plan" || provider == "ark-coding-plan" || provider == "xiaomi") { + if apiType == "anthropic-messages" && (provider == "deepseek" || provider == "bailian" || provider == "bailian-coding-plan" || provider == "ark" || provider == "ark-coding-plan" || provider == "xiaomi") { return "anthropic" } switch provider { diff --git a/agent/app/service/agents_local.go b/agent/app/service/agents_local.go index 927892c80..2ed2a5cc9 100644 --- a/agent/app/service/agents_local.go +++ b/agent/app/service/agents_local.go @@ -338,6 +338,34 @@ func deleteRemoteOllamaModel(account *model.AgentAccount, modelName string) erro return nil } +func resolveUpdatedOllamaModels(baseURL, apiKey string, previousModels, models []dto.AgentAccountModel) error { + var available []string + for index, item := range models { + if _, ok := findAgentAccountModelForProvider("ollama", previousModels, item.ID); ok { + continue + } + if available == nil { + var err error + available, err = providercatalog.DiscoverModels(baseURL, apiKey) + if err != nil { + return buserr.WithErr("ErrAgentAccountUnavailable", err) + } + } + found := false + for _, id := range available { + if sameProviderModelID("ollama", id, item.ID) { + models[index].ID = id + found = true + break + } + } + if !found { + return buserr.New("ErrRecordNotFound") + } + } + return nil +} + func resolveExistingOllamaModel(account *model.AgentAccount, modelID string) (string, error) { available, err := providercatalog.DiscoverModels(account.BaseURL, account.APIKey) if err != nil { diff --git a/agent/app/service/agents_minimax_test.go b/agent/app/service/agents_minimax_test.go deleted file mode 100644 index 8a0e66a93..000000000 --- a/agent/app/service/agents_minimax_test.go +++ /dev/null @@ -1,115 +0,0 @@ -package service - -import ( - "encoding/json" - "path/filepath" - "reflect" - "testing" - - "github.com/1Panel-dev/1Panel/agent/app/dto" - "github.com/1Panel-dev/1Panel/agent/app/model" - providercatalog "github.com/1Panel-dev/1Panel/agent/app/provider" -) - -func TestMiniMaxOpenclawModelMetadata(t *testing.T) { - for _, provider := range []string{"minimax", "custom", "bailian-coding-plan"} { - for _, protocol := range []string{"anthropic-messages", "openai-completions"} { - for _, id := range []string{"MiniMax-M3.1-Flash", "MiniMax-M3", "MiniMax-M2.7", "MiniMax-M2.5", "saved-custom"} { - t.Run(provider+"/"+protocol+"/"+id, func(t *testing.T) { - account := &model.AgentAccount{Provider: provider, APIType: protocol, BaseURL: "https://example.test/v1", APIKey: "test-key"} - _, entry, _, _, err := buildOpenclawAccountModelConfig(account, dto.AgentAccountModel{ID: id, Name: "Saved name"}) - if err != nil { - t.Fatal(err) - } - payload, err := json.Marshal(entry) - if err != nil { - t.Fatal(err) - } - var actual modelEntry - if err := json.Unmarshal(payload, &actual); err != nil { - t.Fatal(err) - } - if actual.ID != id || actual.Name != "Saved name" { - t.Fatalf("changed saved identity: %s", payload) - } - if provider == "minimax" && id == "MiniMax-M3.1-Flash" { - if actual.ContextWindow != 1000000 || actual.MaxTokens != 524288 || !reflect.DeepEqual(actual.Input, []string{"text", "image"}) { - t.Fatalf("incorrect direct Flash metadata: %s", payload) - } - } else if actual.ContextWindow != 0 || actual.MaxTokens != 0 { - t.Fatalf("changed existing/gateway limits: %s", payload) - } - }) - } - } - } -} - -func TestMiniMaxPreservesSavedOpenclawMetadata(t *testing.T) { - current := &modelsConfig{Mode: "merge", Providers: map[string]modelProvider{ - "minimax": {Models: []modelEntry{{ID: "MiniMax-M3.1-Flash", Input: []string{"text"}, ContextWindow: 32000, MaxTokens: 4096}}}, - }} - conf := map[string]interface{}{} - if err := applyOpenclawModelsConfig(conf, current); err != nil { - t.Fatal(err) - } - next := &modelsConfig{Mode: "merge", Providers: map[string]modelProvider{ - "minimax": {Models: []modelEntry{{ID: "MiniMax-M3.1-Flash", Input: []string{"text", "image"}, ContextWindow: 1000000, MaxTokens: 524288}}}, - }} - preserveOpenclawModelMetadata(conf, next) - if !reflect.DeepEqual(next.Providers["minimax"].Models, current.Providers["minimax"].Models) { - t.Fatalf("saved metadata changed: %+v", next) - } -} - -func TestMiniMaxDefaultAccountRequest(t *testing.T) { - for _, protocol := range []string{"anthropic-messages", "openai-completions"} { - account := &model.AgentAccount{Provider: "minimax", APIType: protocol} - models, err := buildInitialAgentAccountModels(account, nil) - if err != nil { - t.Fatal(err) - } - selected, err := resolveAgentAccountVerifyModel("minimax", "", models) - if err != nil || selected != "MiniMax-M3.1-Flash" || len(models) != 2 || models[1].ID != "MiniMax-M3" { - t.Fatalf("unexpected default: %s, %+v, %v", selected, models, err) - } - request := providercatalog.BuildVerifyRequest("minimax", protocol, "", "https://example.test", "test-key", selected) - var body map[string]interface{} - if err := json.Unmarshal(request.Body, &body); err != nil || body["model"] != selected { - t.Fatalf("default request: %s, %v", request.Body, err) - } - } -} - -func TestMiniMaxHermesConfiguration(t *testing.T) { - for _, protocol := range []string{"anthropic-messages", "openai-completions"} { - for _, id := range []string{"MiniMax-M3.1-Flash", "MiniMax-M3", "MiniMax-M2.7", "my-custom-model"} { - dir := t.TempDir() - account := &model.AgentAccount{Provider: "minimax", APIType: protocol, BaseURL: "https://api.minimaxi.com/anthropic", APIKey: "test-key"} - if err := writeHermesConfig(dir, account, id, ""); err != nil { - t.Fatal(err) - } - conf, err := readHermesConfig(filepath.Join(dir, "config.yaml")) - if err != nil { - t.Fatal(err) - } - if conf.Model.Default != id || conf.Model.Provider != "minimax-cn" || conf.Model.BaseURL != account.BaseURL { - t.Fatalf("changed Hermes selection: %+v", conf.Model) - } - } - } -} - -func TestMiniMaxExplicitAccountModels(t *testing.T) { - for _, provider := range []string{"minimax", "bailian-coding-plan", "custom"} { - account := &model.AgentAccount{Provider: provider, APIType: "openai-completions"} - requested := []dto.AgentAccountModel{{ID: "MiniMax-M2.5", Name: "Saved legacy"}, {ID: "my-custom-model", Name: "Saved custom"}} - actual, err := buildInitialAgentAccountModels(account, requested) - if err != nil { - t.Fatal(err) - } - if !reflect.DeepEqual(actual, requested) { - t.Fatalf("changed explicit %s models: %+v", provider, actual) - } - } -} diff --git a/agent/app/service/agents_utils.go b/agent/app/service/agents_utils.go index f242909d6..d1ca6ac4d 100644 --- a/agent/app/service/agents_utils.go +++ b/agent/app/service/agents_utils.go @@ -114,14 +114,14 @@ func ensureContainerRunning(containerName string) error { return nil } -func resolveAgentAccountInput(provider, apiType, authMode, apiKey, baseURL, modelID string, validateAvailability, allowEmptyModel bool) (resolvedAgentAccountInput, error) { +func resolveAgentAccountInput(provider, apiType, authMode, apiKey, baseURL, modelID string, validateAvailability, allowEmptyModel bool, accountType ...string) (resolvedAgentAccountInput, error) { resolvedAPIKey := strings.TrimSpace(apiKey) resolvedAPIType := strings.TrimSpace(apiType) - resolvedAuthMode, err := providercatalog.ResolveAuthMode(provider, resolvedAPIType, authMode) + resolvedAuthMode, err := providercatalog.ResolveAuthMode(provider, resolvedAPIType, authMode, accountType...) if err != nil { return resolvedAgentAccountInput{}, err } - resolvedBaseURL, err := providercatalog.ResolveBaseURL(provider, resolvedAPIType, baseURL) + resolvedBaseURL, err := providercatalog.ResolveBaseURL(provider, resolvedAPIType, baseURL, accountType...) if err != nil { if strings.Contains(err.Error(), "base url is required") { return resolvedAgentAccountInput{}, buserr.New("ErrAgentBaseURLRequired") @@ -774,10 +774,6 @@ type modelEntry struct { MaxTokens int `json:"maxTokens,omitempty"` } -func requiresOpenclawProviderModels(provider string) bool { - return provider != "gemini" -} - func applyOpenclawModelsConfig(conf map[string]interface{}, models *modelsConfig) error { if models == nil { delete(conf, "models") @@ -1265,7 +1261,7 @@ func buildOpenclawModelsFromAccount(account *model.AgentAccount, selectedModel s if primaryModel == "" { return "", nil, nil, buserr.New("ErrAgentModelNotInAccount") } - if !requiresOpenclawProviderModels(account.Provider) { + if account.Provider == "gemini" && providerCfg.Api == "google-generative-ai" { return primaryModel, defaultsModels, nil, nil } providerCfg.Models = entries @@ -1349,21 +1345,7 @@ func buildInitialAgentAccountModels(account *model.AgentAccount, requested []dto if len(requested) > 0 { return normalizeAgentAccountModels(account, requested) } - defaultModels := providercatalog.DefaultModels(account.Provider, account.APIType) - if len(defaultModels) == 0 { - if requiresInitialAgentAccountModels(account.Provider) { - return nil, buserr.New("ErrAgentAccountModelsRequired") - } - return nil, nil - } - requested = make([]dto.AgentAccountModel, 0, len(defaultModels)) - for _, item := range defaultModels { - requested = append(requested, dto.AgentAccountModel{ - ID: item.ID, - Name: item.Name, - }) - } - return normalizeAgentAccountModels(account, requested) + return nil, buserr.New("ErrAgentAccountModelsRequired") } func buildDiscoveredAgentAccountModels(modelIDs []string) []dto.AgentAccountModel { @@ -1402,39 +1384,6 @@ func loadAgentAccountModels(account *model.AgentAccount) ([]dto.AgentAccountMode return listPersistedAgentAccountModels(account.ID) } -func MergeCatalogAgentAccountModelsForMigration(account *model.AgentAccount, existing []dto.AgentAccountModel) ([]dto.AgentAccountModel, error) { - if account == nil { - return nil, fmt.Errorf("account is required") - } - meta, ok := providercatalog.Get(account.Provider) - if !ok || len(meta.Models) == 0 { - return append([]dto.AgentAccountModel(nil), existing...), nil - } - requested := append([]dto.AgentAccountModel(nil), existing...) - seen := make(map[string]struct{}, len(existing)) - for _, item := range existing { - target := strings.TrimSpace(item.ID) - if target == "" { - continue - } - seen[target] = struct{}{} - } - for _, item := range meta.Models { - target := strings.TrimSpace(item.ID) - if _, ok := seen[target]; ok { - continue - } - requested = append(requested, dto.AgentAccountModel{ - ID: item.ID, - Name: item.Name, - }) - } - if len(requested) == len(existing) { - return append([]dto.AgentAccountModel(nil), existing...), nil - } - return normalizeAgentAccountModels(account, requested) -} - func listPersistedAgentAccountModels(accountID uint) ([]dto.AgentAccountModel, error) { if accountID == 0 { return nil, nil @@ -1487,10 +1436,14 @@ func normalizeAgentAccountModels(account *model.AgentAccount, models []dto.Agent if strings.TrimSpace(normalizedItem.ID) == "" { continue } - if _, ok := seen[normalizedItem.ID]; ok { + modelKey := normalizedItem.ID + if account.Provider == "ollama" && !strings.Contains(path.Base(modelKey), ":") { + modelKey += ":latest" + } + if _, ok := seen[modelKey]; ok { continue } - seen[normalizedItem.ID] = struct{}{} + seen[modelKey] = struct{}{} normalized = append(normalized, normalizedItem) } if len(normalized) == 0 { @@ -1515,15 +1468,6 @@ func normalizeAgentAccountModel(account *model.AgentAccount, model dto.AgentAcco }, nil } -func requiresInitialAgentAccountModels(provider string) bool { - switch provider { - case "custom", "vllm", "ollama", "llmman": - return true - default: - return false - } -} - func sameProviderModelID(provider, left, right string) bool { leftTrimmed := strings.TrimSpace(left) rightTrimmed := strings.TrimSpace(right) diff --git a/agent/cmd/server/docs/x-log.json b/agent/cmd/server/docs/x-log.json index f52e9699a..9b8d1d8d0 100644 --- a/agent/cmd/server/docs/x-log.json +++ b/agent/cmd/server/docs/x-log.json @@ -8,107 +8,6 @@ "formatZH": "更新 Ollama 绑定域名 [domain]", "formatEN": "update Ollama bind domain [domain]" }, - "/xpack/model/downloader/featured/sync/status": { - "bodyKeys": [ - "value" - ], - "paramKeys": [], - "beforeFunctions": [], - "formatZH": "更新推荐模型自动同步 [value]", - "formatEN": "update featured model automatic synchronization [value]" - }, - "/xpack/model/downloader/hf/download": { - "bodyKeys": [ - "repoID", - "revision" - ], - "paramKeys": [], - "beforeFunctions": [], - "formatZH": "下载 Hugging Face 模型 [repoID]", - "formatEN": "download Hugging Face model [repoID]" - }, - "/xpack/model/downloader/local/delete": { - "bodyKeys": [ - "name" - ], - "paramKeys": [], - "beforeFunctions": [], - "formatZH": "删除本地模型 [name]", - "formatEN": "delete local model [name]" - }, - "/xpack/model/downloader/modelscope/download": { - "bodyKeys": [ - "repoID", - "revision" - ], - "paramKeys": [], - "beforeFunctions": [], - "formatZH": "下载 ModelScope 模型 [repoID]", - "formatEN": "download ModelScope model [repoID]" - }, - "/xpack/model/downloader/settings": { - "bodyKeys": [ - "modelDir" - ], - "paramKeys": [], - "beforeFunctions": [], - "formatZH": "更新模型下载设置 [modelDir]", - "formatEN": "update model downloader settings [modelDir]" - }, - "/xpack/model/downloader/tasks/cancel": { - "bodyKeys": [ - "id" - ], - "paramKeys": [], - "beforeFunctions": [ - { - "input_column": "id", - "input_value": "id", - "isList": false, - "db": "model_download_tasks", - "output_column": "repo_id", - "output_value": "repoID" - } - ], - "formatZH": "取消模型下载任务 [repoID]", - "formatEN": "cancel model download task [repoID]" - }, - "/xpack/model/downloader/tasks/remove": { - "bodyKeys": [ - "id" - ], - "paramKeys": [], - "beforeFunctions": [ - { - "input_column": "id", - "input_value": "id", - "isList": false, - "db": "model_download_tasks", - "output_column": "repo_id", - "output_value": "repoID" - } - ], - "formatZH": "移除模型下载任务 [repoID]", - "formatEN": "remove model download task [repoID]" - }, - "/xpack/model/downloader/tasks/retry": { - "bodyKeys": [ - "id" - ], - "paramKeys": [], - "beforeFunctions": [ - { - "input_column": "id", - "input_value": "id", - "isList": false, - "db": "model_download_tasks", - "output_column": "repo_id", - "output_value": "repoID" - } - ], - "formatZH": "重试模型下载任务 [repoID]", - "formatEN": "retry model download task [repoID]" - }, "/ai/ollama/close": { "bodyKeys": [ "name" @@ -3815,6 +3714,25 @@ "formatZH": "[domain] PHP 配置修改", "formatEN": "[domain] PHP conf update" }, + "/runtimes/php/extensions/import": { + "bodyKeys": [ + "name" + ], + "paramKeys": [], + "beforeFunctions": [], + "formatZH": "同步 PHP 扩展模版 [name]", + "formatEN": "Sync PHP extension template [name]" + }, + "/runtimes/php/extensions/push": { + "bodyKeys": [ + "sourceNode", + "targetNodes" + ], + "paramKeys": [], + "beforeFunctions": [], + "formatZH": "推送 PHP 扩展模版 [sourceNode] 至 [targetNodes]", + "formatEN": "Push PHP extension template from [sourceNode] to [targetNodes]" + }, "/runtimes/php/update": { "bodyKeys": [ "websiteId" @@ -4211,6 +4129,282 @@ "formatZH": "扫描系统垃圾文件", "formatEN": "scan System Junk Files" }, + "/vms": { + "bodyKeys": [ + "name" + ], + "paramKeys": [], + "beforeFunctions": [], + "formatZH": "创建虚拟机 [name]", + "formatEN": "create VM [name]" + }, + "/vms/del": { + "bodyKeys": [ + "id" + ], + "paramKeys": [], + "beforeFunctions": [ + { + "input_column": "id", + "input_value": "id", + "isList": false, + "db": "virtual_machines", + "output_column": "name", + "output_value": "name" + } + ], + "formatZH": "删除虚拟机 [name]", + "formatEN": "delete VM [name]" + }, + "/vms/disks/resize": { + "bodyKeys": [ + "name", + "target", + "sizeGiB" + ], + "paramKeys": [], + "beforeFunctions": [], + "formatZH": "扩容虚拟机 [name] 磁盘 [target] 至 [sizeGiB] GiB", + "formatEN": "expand VM [name] disk [target] to [sizeGiB] GiB" + }, + "/vms/environment/enable": { + "bodyKeys": [], + "paramKeys": [], + "beforeFunctions": [], + "formatZH": "启用虚拟机运行环境", + "formatEN": "enable VM runtime environment" + }, + "/vms/iso": { + "bodyKeys": [ + "name", + "type" + ], + "paramKeys": [], + "beforeFunctions": [], + "formatZH": "创建虚拟机镜像 [name] [type]", + "formatEN": "create VM ISO [name] [type]" + }, + "/vms/iso/del": { + "bodyKeys": [ + "id" + ], + "paramKeys": [], + "beforeFunctions": [ + { + "input_column": "id", + "input_value": "id", + "isList": false, + "db": "vm_isos", + "output_column": "name", + "output_value": "name" + } + ], + "formatZH": "删除虚拟机镜像 [name]", + "formatEN": "delete VM ISO [name]" + }, + "/vms/iso/update": { + "bodyKeys": [ + "name", + "type" + ], + "paramKeys": [], + "beforeFunctions": [], + "formatZH": "更新虚拟机镜像 [name] [type]", + "formatEN": "update VM ISO [name] [type]" + }, + "/vms/networks": { + "bodyKeys": [ + "name", + "type" + ], + "paramKeys": [], + "beforeFunctions": [], + "formatZH": "创建虚拟机网络 [name] [type]", + "formatEN": "create VM network [name] [type]" + }, + "/vms/networks/del": { + "bodyKeys": [ + "id" + ], + "paramKeys": [], + "beforeFunctions": [ + { + "input_column": "id", + "input_value": "id", + "isList": false, + "db": "vm_networks", + "output_column": "name", + "output_value": "name" + } + ], + "formatZH": "删除虚拟机网络 [name]", + "formatEN": "delete VM network [name]" + }, + "/vms/networks/update": { + "bodyKeys": [ + "id" + ], + "paramKeys": [], + "beforeFunctions": [ + { + "input_column": "id", + "input_value": "id", + "isList": false, + "db": "vm_networks", + "output_column": "name", + "output_value": "name" + } + ], + "formatZH": "更新虚拟机网络 [name]", + "formatEN": "update VM network [name]" + }, + "/vms/operate": { + "bodyKeys": [ + "name", + "operate" + ], + "paramKeys": [], + "beforeFunctions": [], + "formatZH": "操作虚拟机 [name] [operate]", + "formatEN": "operate VM [name] [operate]" + }, + "/vms/orphans/clean": { + "bodyKeys": [], + "paramKeys": [], + "beforeFunctions": [], + "formatZH": "清理虚拟机孤立数据", + "formatEN": "clean VM orphaned data" + }, + "/vms/rename": { + "bodyKeys": [ + "name", + "newName" + ], + "paramKeys": [], + "beforeFunctions": [], + "formatZH": "重命名虚拟机 [name] 为 [newName]", + "formatEN": "rename VM [name] to [newName]" + }, + "/vms/snapshots": { + "bodyKeys": [ + "name", + "snapshotName" + ], + "paramKeys": [], + "beforeFunctions": [], + "formatZH": "创建虚拟机 [name] 快照 [snapshotName]", + "formatEN": "create VM [name] snapshot [snapshotName]" + }, + "/vms/snapshots/del": { + "bodyKeys": [ + "name", + "snapshotName" + ], + "paramKeys": [], + "beforeFunctions": [], + "formatZH": "删除虚拟机 [name] 快照 [snapshotName]", + "formatEN": "delete VM [name] snapshot [snapshotName]" + }, + "/vms/snapshots/recover": { + "bodyKeys": [ + "name", + "snapshotName" + ], + "paramKeys": [], + "beforeFunctions": [], + "formatZH": "恢复虚拟机 [name] 快照 [snapshotName]", + "formatEN": "recover VM [name] snapshot [snapshotName]" + }, + "/vms/storages": { + "bodyKeys": [ + "name", + "type" + ], + "paramKeys": [], + "beforeFunctions": [], + "formatZH": "创建虚拟机存储 [name] [type]", + "formatEN": "create VM storage [name] [type]" + }, + "/vms/storages/del": { + "bodyKeys": [ + "id" + ], + "paramKeys": [], + "beforeFunctions": [ + { + "input_column": "id", + "input_value": "id", + "isList": false, + "db": "vm_storages", + "output_column": "name", + "output_value": "name" + } + ], + "formatZH": "删除虚拟机存储 [name]", + "formatEN": "delete VM storage [name]" + }, + "/vms/storages/update": { + "bodyKeys": [ + "id" + ], + "paramKeys": [], + "beforeFunctions": [ + { + "input_column": "id", + "input_value": "id", + "isList": false, + "db": "vm_storages", + "output_column": "name", + "output_value": "name" + } + ], + "formatZH": "更新虚拟机存储 [name]", + "formatEN": "update VM storage [name]" + }, + "/vms/sync": { + "bodyKeys": [], + "paramKeys": [], + "beforeFunctions": [], + "formatZH": "同步虚拟机", + "formatEN": "sync virtual machines" + }, + "/vms/templates": { + "bodyKeys": [ + "name", + "templateName" + ], + "paramKeys": [], + "beforeFunctions": [], + "formatZH": "创建虚拟机 [name] 模板 [templateName]", + "formatEN": "create VM [name] template [templateName]" + }, + "/vms/templates/del": { + "bodyKeys": [ + "id" + ], + "paramKeys": [], + "beforeFunctions": [ + { + "input_column": "id", + "input_value": "id", + "isList": false, + "db": "vm_templates", + "output_column": "name", + "output_value": "name" + } + ], + "formatZH": "删除虚拟机模板 [name]", + "formatEN": "delete VM template [name]" + }, + "/vms/update": { + "bodyKeys": [ + "name" + ], + "paramKeys": [], + "beforeFunctions": [], + "formatZH": "更新虚拟机 [name]", + "formatEN": "update VM [name]" + }, "/websites": { "bodyKeys": [ "alias" @@ -5011,6 +5205,107 @@ "formatZH": "更新离线告警日志 [id]", "formatEN": "update offline alert log [id]" }, + "/xpack/model/downloader/featured/sync/status": { + "bodyKeys": [ + "value" + ], + "paramKeys": [], + "beforeFunctions": [], + "formatZH": "更新推荐模型自动同步 [value]", + "formatEN": "update featured model automatic synchronization [value]" + }, + "/xpack/model/downloader/hf/download": { + "bodyKeys": [ + "repoID", + "revision" + ], + "paramKeys": [], + "beforeFunctions": [], + "formatZH": "下载 Hugging Face 模型 [repoID]", + "formatEN": "download Hugging Face model [repoID]" + }, + "/xpack/model/downloader/local/delete": { + "bodyKeys": [ + "name" + ], + "paramKeys": [], + "beforeFunctions": [], + "formatZH": "删除本地模型 [name]", + "formatEN": "delete local model [name]" + }, + "/xpack/model/downloader/modelscope/download": { + "bodyKeys": [ + "repoID", + "revision" + ], + "paramKeys": [], + "beforeFunctions": [], + "formatZH": "下载 ModelScope 模型 [repoID]", + "formatEN": "download ModelScope model [repoID]" + }, + "/xpack/model/downloader/settings": { + "bodyKeys": [ + "modelDir" + ], + "paramKeys": [], + "beforeFunctions": [], + "formatZH": "更新模型下载设置 [modelDir]", + "formatEN": "update model downloader settings [modelDir]" + }, + "/xpack/model/downloader/tasks/cancel": { + "bodyKeys": [ + "id" + ], + "paramKeys": [], + "beforeFunctions": [ + { + "input_column": "id", + "input_value": "id", + "isList": false, + "db": "model_download_tasks", + "output_column": "repo_id", + "output_value": "repoID" + } + ], + "formatZH": "取消模型下载任务 [repoID]", + "formatEN": "cancel model download task [repoID]" + }, + "/xpack/model/downloader/tasks/remove": { + "bodyKeys": [ + "id" + ], + "paramKeys": [], + "beforeFunctions": [ + { + "input_column": "id", + "input_value": "id", + "isList": false, + "db": "model_download_tasks", + "output_column": "repo_id", + "output_value": "repoID" + } + ], + "formatZH": "移除模型下载任务 [repoID]", + "formatEN": "remove model download task [repoID]" + }, + "/xpack/model/downloader/tasks/retry": { + "bodyKeys": [ + "id" + ], + "paramKeys": [], + "beforeFunctions": [ + { + "input_column": "id", + "input_value": "id", + "isList": false, + "db": "model_download_tasks", + "output_column": "repo_id", + "output_value": "repoID" + } + ], + "formatZH": "重试模型下载任务 [repoID]", + "formatEN": "retry model download task [repoID]" + }, "/xpack/monitor/config/global": { "bodyKeys": [], "paramKeys": [], @@ -5130,6 +5425,17 @@ "formatZH": "创建 vLLM [name]", "formatEN": "create vLLM [name]" }, + "/xpack/vllm/monitor/setting/update": { + "bodyKeys": [ + "vllmID", + "key", + "value" + ], + "paramKeys": [], + "beforeFunctions": [], + "formatZH": "修改 vLLM [vllmID] 监控设置 [key]-[value]", + "formatEN": "update vLLM [vllmID] monitor setting [key]-[value]" + }, "/xpack/vllm/operate": { "bodyKeys": [ "id", @@ -5159,282 +5465,6 @@ "formatZH": "更新 vLLM [name]", "formatEN": "update vLLM [name]" }, - "/vms": { - "bodyKeys": [ - "name" - ], - "paramKeys": [], - "beforeFunctions": [], - "formatZH": "创建虚拟机 [name]", - "formatEN": "create VM [name]" - }, - "/vms/del": { - "bodyKeys": [ - "id" - ], - "paramKeys": [], - "beforeFunctions": [ - { - "input_column": "id", - "input_value": "id", - "isList": false, - "db": "virtual_machines", - "output_column": "name", - "output_value": "name" - } - ], - "formatZH": "删除虚拟机 [name]", - "formatEN": "delete VM [name]" - }, - "/vms/disks/resize": { - "bodyKeys": [ - "name", - "target", - "sizeGiB" - ], - "paramKeys": [], - "beforeFunctions": [], - "formatZH": "扩容虚拟机 [name] 磁盘 [target] 至 [sizeGiB] GiB", - "formatEN": "expand VM [name] disk [target] to [sizeGiB] GiB" - }, - "/vms/environment/enable": { - "bodyKeys": [], - "paramKeys": [], - "beforeFunctions": [], - "formatZH": "启用虚拟机运行环境", - "formatEN": "enable VM runtime environment" - }, - "/vms/iso": { - "bodyKeys": [ - "name", - "type" - ], - "paramKeys": [], - "beforeFunctions": [], - "formatZH": "创建虚拟机镜像 [name] [type]", - "formatEN": "create VM ISO [name] [type]" - }, - "/vms/iso/del": { - "bodyKeys": [ - "id" - ], - "paramKeys": [], - "beforeFunctions": [ - { - "input_column": "id", - "input_value": "id", - "isList": false, - "db": "vm_isos", - "output_column": "name", - "output_value": "name" - } - ], - "formatZH": "删除虚拟机镜像 [name]", - "formatEN": "delete VM ISO [name]" - }, - "/vms/iso/update": { - "bodyKeys": [ - "name", - "type" - ], - "paramKeys": [], - "beforeFunctions": [], - "formatZH": "更新虚拟机镜像 [name] [type]", - "formatEN": "update VM ISO [name] [type]" - }, - "/vms/networks": { - "bodyKeys": [ - "name", - "type" - ], - "paramKeys": [], - "beforeFunctions": [], - "formatZH": "创建虚拟机网络 [name] [type]", - "formatEN": "create VM network [name] [type]" - }, - "/vms/networks/del": { - "bodyKeys": [ - "id" - ], - "paramKeys": [], - "beforeFunctions": [ - { - "input_column": "id", - "input_value": "id", - "isList": false, - "db": "vm_networks", - "output_column": "name", - "output_value": "name" - } - ], - "formatZH": "删除虚拟机网络 [name]", - "formatEN": "delete VM network [name]" - }, - "/vms/networks/update": { - "bodyKeys": [ - "id" - ], - "paramKeys": [], - "beforeFunctions": [ - { - "input_column": "id", - "input_value": "id", - "isList": false, - "db": "vm_networks", - "output_column": "name", - "output_value": "name" - } - ], - "formatZH": "更新虚拟机网络 [name]", - "formatEN": "update VM network [name]" - }, - "/vms/operate": { - "bodyKeys": [ - "name", - "operate" - ], - "paramKeys": [], - "beforeFunctions": [], - "formatZH": "操作虚拟机 [name] [operate]", - "formatEN": "operate VM [name] [operate]" - }, - "/vms/orphans/clean": { - "bodyKeys": [], - "paramKeys": [], - "beforeFunctions": [], - "formatZH": "清理虚拟机孤立数据", - "formatEN": "clean VM orphaned data" - }, - "/vms/rename": { - "bodyKeys": [ - "name", - "newName" - ], - "paramKeys": [], - "beforeFunctions": [], - "formatZH": "重命名虚拟机 [name] 为 [newName]", - "formatEN": "rename VM [name] to [newName]" - }, - "/vms/snapshots": { - "bodyKeys": [ - "name", - "snapshotName" - ], - "paramKeys": [], - "beforeFunctions": [], - "formatZH": "创建虚拟机 [name] 快照 [snapshotName]", - "formatEN": "create VM [name] snapshot [snapshotName]" - }, - "/vms/snapshots/del": { - "bodyKeys": [ - "name", - "snapshotName" - ], - "paramKeys": [], - "beforeFunctions": [], - "formatZH": "删除虚拟机 [name] 快照 [snapshotName]", - "formatEN": "delete VM [name] snapshot [snapshotName]" - }, - "/vms/snapshots/recover": { - "bodyKeys": [ - "name", - "snapshotName" - ], - "paramKeys": [], - "beforeFunctions": [], - "formatZH": "恢复虚拟机 [name] 快照 [snapshotName]", - "formatEN": "recover VM [name] snapshot [snapshotName]" - }, - "/vms/storages": { - "bodyKeys": [ - "name", - "type" - ], - "paramKeys": [], - "beforeFunctions": [], - "formatZH": "创建虚拟机存储 [name] [type]", - "formatEN": "create VM storage [name] [type]" - }, - "/vms/storages/del": { - "bodyKeys": [ - "id" - ], - "paramKeys": [], - "beforeFunctions": [ - { - "input_column": "id", - "input_value": "id", - "isList": false, - "db": "vm_storages", - "output_column": "name", - "output_value": "name" - } - ], - "formatZH": "删除虚拟机存储 [name]", - "formatEN": "delete VM storage [name]" - }, - "/vms/storages/update": { - "bodyKeys": [ - "id" - ], - "paramKeys": [], - "beforeFunctions": [ - { - "input_column": "id", - "input_value": "id", - "isList": false, - "db": "vm_storages", - "output_column": "name", - "output_value": "name" - } - ], - "formatZH": "更新虚拟机存储 [name]", - "formatEN": "update VM storage [name]" - }, - "/vms/sync": { - "bodyKeys": [], - "paramKeys": [], - "beforeFunctions": [], - "formatZH": "同步虚拟机", - "formatEN": "sync virtual machines" - }, - "/vms/templates": { - "bodyKeys": [ - "name", - "templateName" - ], - "paramKeys": [], - "beforeFunctions": [], - "formatZH": "创建虚拟机 [name] 模板 [templateName]", - "formatEN": "create VM [name] template [templateName]" - }, - "/vms/templates/del": { - "bodyKeys": [ - "id" - ], - "paramKeys": [], - "beforeFunctions": [ - { - "input_column": "id", - "input_value": "id", - "isList": false, - "db": "vm_templates", - "output_column": "name", - "output_value": "name" - } - ], - "formatZH": "删除虚拟机模板 [name]", - "formatEN": "delete VM template [name]" - }, - "/vms/update": { - "bodyKeys": [ - "name" - ], - "paramKeys": [], - "beforeFunctions": [], - "formatZH": "更新虚拟机 [name]", - "formatEN": "update VM [name]" - }, "/xpack/waf/block/export": { "bodyKeys": [], "paramKeys": [], diff --git a/agent/init/migration/migrate.go b/agent/init/migration/migrate.go index b802551e9..4b96638cd 100644 --- a/agent/init/migration/migrate.go +++ b/agent/init/migration/migrate.go @@ -120,6 +120,7 @@ func agentDBMigrations() []*gormigrate.Migration { migrations.MigrateVMDatabase, migrations.UpdateModelServicesQuickJumpRouter, migrations.AddAgentAccountVerificationResult, + migrations.AddAgentAccountType, migrations.AddGPUGroup, } } diff --git a/agent/init/migration/migrations/agent_account_type.go b/agent/init/migration/migrations/agent_account_type.go new file mode 100644 index 000000000..428c27d12 --- /dev/null +++ b/agent/init/migration/migrations/agent_account_type.go @@ -0,0 +1,27 @@ +package migrations + +import ( + "github.com/1Panel-dev/1Panel/agent/app/model" + "github.com/1Panel-dev/1Panel/agent/app/provider" + "github.com/go-gormigrate/gormigrate/v2" + "gorm.io/gorm" +) + +var AddAgentAccountType = &gormigrate.Migration{ + ID: "202611120002", + Migrate: func(tx *gorm.DB) error { + if err := tx.AutoMigrate(&model.AgentAccount{}); err != nil { + return err + } + for key := range provider.All() { + preset, ok := provider.FindAccountType(key, "") + if !ok { + continue + } + if err := tx.Model(&model.AgentAccount{}).Where("provider = ? AND (account_type = ? OR account_type IS NULL)", key, "").Update("account_type", preset.Key).Error; err != nil { + return err + } + } + return nil + }, +} diff --git a/agent/init/migration/migrations/utils/agent_account_model_pool.go b/agent/init/migration/migrations/utils/agent_account_model_pool.go index 2e94bf0b3..498a559e0 100644 --- a/agent/init/migration/migrations/utils/agent_account_model_pool.go +++ b/agent/init/migration/migrations/utils/agent_account_model_pool.go @@ -7,7 +7,6 @@ import ( "github.com/1Panel-dev/1Panel/agent/app/dto" "github.com/1Panel-dev/1Panel/agent/app/model" providercatalog "github.com/1Panel-dev/1Panel/agent/app/provider" - "github.com/1Panel-dev/1Panel/agent/app/service" "gorm.io/gorm" ) @@ -57,7 +56,6 @@ func buildMigratedAgentAccountModels(tx *gorm.DB, account *legacyAgentAccountMod if account == nil { return nil, nil } - baseAccount := account.AgentAccount requested := make([]dto.AgentAccountModel, 0) if strings.TrimSpace(account.LegacyModels) != "" { if err := json.Unmarshal([]byte(account.LegacyModels), &requested); err != nil { @@ -93,14 +91,7 @@ func buildMigratedAgentAccountModels(tx *gorm.DB, account *legacyAgentAccountMod appendModel(agent.Model) } } - models, err := service.MergeCatalogAgentAccountModelsForMigration(&baseAccount, requested) - if err != nil { - if strings.TrimSpace(err.Error()) == "model is required" { - return nil, nil - } - return nil, err - } - return models, nil + return requested, nil } func NormalizeAgentAccountModelIDs(tx *gorm.DB) error { diff --git a/agent/utils/terminal/ai/client.go b/agent/utils/terminal/ai/client.go index e5be67e17..37df1f025 100644 --- a/agent/utils/terminal/ai/client.go +++ b/agent/utils/terminal/ai/client.go @@ -7,7 +7,6 @@ import ( "fmt" "io" "net/http" - "net/url" "strings" "time" "unicode/utf8" @@ -102,6 +101,9 @@ func NewClient(cfg ClientConfig) (Client, error) { cfg.Provider = providerKey cfg.BaseURL = baseURL cfg.APIType = normalizeClientAPIType(providerKey, cfg.APIType) + if providercatalog.Purpose(cfg.APIType) != "text" { + return nil, fmt.Errorf("api type %s does not support text generation", cfg.APIType) + } authMode, err := providercatalog.ResolveAuthMode(providerKey, cfg.APIType, cfg.AuthMode) if err != nil { return nil, err @@ -149,7 +151,7 @@ func (c *terminalAIClient) chatCompletionOpenAI(ctx context.Context, req ChatCom if err != nil { return nil, fmt.Errorf("marshal request: %w", err) } - httpReq, err := http.NewRequestWithContext(ctx, http.MethodPost, buildChatCompletionsURL(c.config.BaseURL), bytes.NewReader(body)) + httpReq, err := http.NewRequestWithContext(ctx, http.MethodPost, providercatalog.BuildTextRequestURL(c.config.APIType, c.config.BaseURL, c.config.Model), bytes.NewReader(body)) if err != nil { return nil, fmt.Errorf("create request: %w", err) } @@ -193,7 +195,7 @@ func (c *terminalAIClient) chatCompletionOpenAIResponses(ctx context.Context, re if err != nil { return nil, fmt.Errorf("marshal request: %w", err) } - httpReq, err := http.NewRequestWithContext(ctx, http.MethodPost, buildResponsesURL(c.config.BaseURL), bytes.NewReader(body)) + httpReq, err := http.NewRequestWithContext(ctx, http.MethodPost, providercatalog.BuildTextRequestURL(c.config.APIType, c.config.BaseURL, c.config.Model), bytes.NewReader(body)) if err != nil { return nil, fmt.Errorf("create request: %w", err) } @@ -241,7 +243,7 @@ func (c *terminalAIClient) chatCompletionAnthropic(ctx context.Context, req Chat if err != nil { return nil, fmt.Errorf("marshal request: %w", err) } - httpReq, err := http.NewRequestWithContext(ctx, http.MethodPost, buildAnthropicMessagesURL(c.config.BaseURL), bytes.NewReader(body)) + httpReq, err := http.NewRequestWithContext(ctx, http.MethodPost, providercatalog.BuildTextRequestURL(c.config.APIType, c.config.BaseURL, c.config.Model), bytes.NewReader(body)) if err != nil { return nil, fmt.Errorf("create request: %w", err) } @@ -291,7 +293,7 @@ func (c *terminalAIClient) chatCompletionGemini(ctx context.Context, req ChatCom if err != nil { return nil, fmt.Errorf("marshal request: %w", err) } - httpReq, err := http.NewRequestWithContext(ctx, http.MethodPost, buildGeminiGenerateContentURL(c.config.BaseURL, strings.TrimSpace(c.config.Model)), bytes.NewReader(body)) + httpReq, err := http.NewRequestWithContext(ctx, http.MethodPost, providercatalog.BuildTextRequestURL(c.config.APIType, c.config.BaseURL, c.config.Model), bytes.NewReader(body)) if err != nil { return nil, fmt.Errorf("create request: %w", err) } @@ -509,81 +511,6 @@ func normalizeBaseURL(provider, rawBaseURL string) string { return strings.TrimRight(baseURL, "/") } -func buildChatCompletionsURL(baseURL string) string { - baseURL = strings.TrimRight(strings.TrimSpace(baseURL), "/") - if strings.HasSuffix(baseURL, "/chat/completions") { - return baseURL - } - parsed, err := url.Parse(baseURL) - if err != nil { - return baseURL + "/chat/completions" - } - switch { - case strings.HasSuffix(parsed.Path, "/v1"): - parsed.Path += "/chat/completions" - case strings.HasSuffix(parsed.Path, "/v1beta"): - parsed.Path += "/chat/completions" - default: - parsed.Path = strings.TrimRight(parsed.Path, "/") + "/v1/chat/completions" - } - return strings.TrimRight(parsed.String(), "/") -} - -func buildResponsesURL(baseURL string) string { - baseURL = strings.TrimRight(strings.TrimSpace(baseURL), "/") - if strings.HasSuffix(baseURL, "/responses") { - return baseURL - } - parsed, err := url.Parse(baseURL) - if err != nil { - return baseURL + "/responses" - } - if strings.HasSuffix(parsed.Path, "/v1") { - parsed.Path += "/responses" - } else { - parsed.Path = strings.TrimRight(parsed.Path, "/") + "/v1/responses" - } - return strings.TrimRight(parsed.String(), "/") -} - -func buildAnthropicMessagesURL(baseURL string) string { - baseURL = strings.TrimRight(strings.TrimSpace(baseURL), "/") - if strings.HasSuffix(baseURL, "/messages") { - return baseURL - } - parsed, err := url.Parse(baseURL) - if err != nil { - return baseURL + "/messages" - } - if strings.HasSuffix(parsed.Path, "/v1") { - parsed.Path += "/messages" - } else { - parsed.Path = strings.TrimRight(parsed.Path, "/") + "/v1/messages" - } - return strings.TrimRight(parsed.String(), "/") -} - -func buildGeminiGenerateContentURL(baseURL, model string) string { - baseURL = strings.TrimRight(strings.TrimSpace(baseURL), "/") - model = strings.TrimSpace(model) - if model == "" { - model = "gemini-3-flash-preview" - } - parsed, err := url.Parse(baseURL) - if err != nil { - return strings.TrimRight(baseURL, "/") + "/v1beta/models/" + model + ":generateContent" - } - if strings.Contains(parsed.Path, "/models/") && strings.HasSuffix(parsed.Path, ":generateContent") { - return parsed.String() - } - if strings.Contains(parsed.Path, "/v1beta") { - parsed.Path = strings.TrimRight(parsed.Path, "/") + "/models/" + model + ":generateContent" - } else { - parsed.Path = strings.TrimRight(parsed.Path, "/") + "/v1beta/models/" + model + ":generateContent" - } - return parsed.String() -} - func thinkingModeForModel(model string) *ThinkingMode { if strings.EqualFold(strings.TrimSpace(model), "kimi-k2.5") { return &ThinkingMode{Type: "disabled"} diff --git a/agent/utils/terminal/ai/config_runtime.go b/agent/utils/terminal/ai/config_runtime.go index 155288c7e..d44348ac0 100644 --- a/agent/utils/terminal/ai/config_runtime.go +++ b/agent/utils/terminal/ai/config_runtime.go @@ -50,11 +50,11 @@ func ResolveGeneratorConfig(accountID uint) (GeneratorConfig, time.Duration, err if provider == "" { return GeneratorConfig{}, 0, fmt.Errorf("agent account provider is required") } - apiType := strings.TrimSpace(account.APIType) - if providercatalog.IsImageAPIType(apiType) { + apiType := normalizeClientAPIType(provider, account.APIType) + if providercatalog.Purpose(apiType) != "text" { return GeneratorConfig{}, 0, fmt.Errorf("api type %s does not support text generation", apiType) } - model, err := resolveAccountModelConfig(account.ID, provider) + model, err := resolveAccountModelConfig(account.ID) if err != nil { return GeneratorConfig{}, 0, err } @@ -90,15 +90,7 @@ func lookupProviderAPIKey(provider string) string { return strings.TrimSpace(os.Getenv(envKey)) } -func defaultModelForProvider(provider string) string { - meta, ok := providercatalog.Get(provider) - if !ok || len(meta.Models) == 0 { - return "" - } - return meta.Models[0].ID -} - -func resolveAccountModelConfig(accountID uint, provider string) (string, error) { +func resolveAccountModelConfig(accountID uint) (string, error) { if accountID > 0 { rows, err := agentAccountModelRepo.List(repo.WithByAccountID(accountID), repo.WithOrderAsc("sort_order"), repo.WithOrderAsc("id")) if err != nil { @@ -108,7 +100,7 @@ func resolveAccountModelConfig(accountID uint, provider string) (string, error) return strings.TrimSpace(rows[0].Model), nil } } - return defaultModelForProvider(provider), nil + return "", nil } func ResolveGeneratorConfigFromAgentSettings() (GeneratorConfig, uint, time.Duration, error) { diff --git a/core/cmd/server/docs/docs.go b/core/cmd/server/docs/docs.go index ed1527a6f..a104a9fde 100644 --- a/core/cmd/server/docs/docs.go +++ b/core/cmd/server/docs/docs.go @@ -314,7 +314,7 @@ const docTemplate = `{ "Timestamp": [] } ], - "summary": "Update model service model", + "summary": "Update model service models", "tags": [ "AI" ] @@ -33977,6 +33977,9 @@ const docTemplate = `{ }, "dto.AgentAccountCreateReq": { "properties": { + "accountType": { + "type": "string" + }, "apiKey": { "type": "string" }, @@ -34035,6 +34038,9 @@ const docTemplate = `{ }, "dto.AgentAccountInfo": { "properties": { + "accountType": { + "type": "string" + }, "apiKey": { "type": "string" }, @@ -34080,9 +34086,19 @@ const docTemplate = `{ "rememberApiKey": { "type": "boolean" }, + "validateAvailability": { + "type": "boolean" + }, "verified": { "type": "boolean" }, + "verifiedAt": { + "format": "date-time", + "type": "string" + }, + "verifyError": { + "type": "string" + }, "verifyModel": { "type": "string" } @@ -34135,25 +34151,33 @@ const docTemplate = `{ }, "dto.AgentAccountModelDiscoverReq": { "properties": { + "accountId": { + "description": "Existing account ID. When provided, connection settings are loaded from the saved account.", + "type": "integer" + }, + "accountType": { + "type": "string" + }, "apiKey": { + "description": "Required when accountId is not provided.", "type": "string" }, "apiType": { + "description": "Required when accountId is not provided.", + "type": "string" + }, + "authMode": { "type": "string" }, "baseURL": { + "description": "Required when accountId is not provided.", "type": "string" }, "provider": { + "description": "Required when accountId is not provided.", "type": "string" } }, - "required": [ - "apiKey", - "apiType", - "baseURL", - "provider" - ], "type": "object" }, "dto.AgentAccountModelReq": { @@ -34172,18 +34196,31 @@ const docTemplate = `{ "accountId": { "type": "integer" }, - "model": { - "$ref": "#/definitions/dto.AgentAccountModel" + "models": { + "type": "array", + "minItems": 1, + "items": { + "$ref": "#/definitions/dto.AgentAccountModel" + } + }, + "verifyModel": { + "type": "string" } }, "required": [ "accountId", - "model" + "models" ], "type": "object" }, "dto.AgentAccountProviderCountReq": { "properties": { + "excludeCodingPlanProviders": { + "items": { + "type": "string" + }, + "type": "array" + }, "providers": { "items": { "type": "string" @@ -34195,6 +34232,12 @@ const docTemplate = `{ }, "dto.AgentAccountSearch": { "properties": { + "excludeCodingPlanProviders": { + "items": { + "type": "string" + }, + "type": "array" + }, "apiType": { "type": "string" }, @@ -34222,6 +34265,9 @@ const docTemplate = `{ }, "dto.AgentAccountUpdateReq": { "properties": { + "accountType": { + "type": "string" + }, "apiKey": { "type": "string" }, @@ -34237,6 +34283,12 @@ const docTemplate = `{ "id": { "type": "integer" }, + "models": { + "items": { + "$ref": "#/definitions/dto.AgentAccountModel" + }, + "type": "array" + }, "name": { "type": "string" }, @@ -44654,8 +44706,28 @@ const docTemplate = `{ }, "type": "object" }, + "dto.ProviderAccountTypeInfo": { + "properties": { + "apiTypes": { + "items": { + "$ref": "#/definitions/dto.ProviderAPIInfo" + }, + "type": "array" + }, + "key": { + "type": "string" + } + }, + "type": "object" + }, "dto.ProviderInfo": { "properties": { + "accountTypes": { + "items": { + "$ref": "#/definitions/dto.ProviderAccountTypeInfo" + }, + "type": "array" + }, "apiTypes": { "items": { "$ref": "#/definitions/dto.ProviderAPIInfo" diff --git a/core/cmd/server/docs/swagger.json b/core/cmd/server/docs/swagger.json index ce71bb0bd..99abf2122 100644 --- a/core/cmd/server/docs/swagger.json +++ b/core/cmd/server/docs/swagger.json @@ -307,7 +307,7 @@ "Timestamp": [] } ], - "summary": "Update model service model", + "summary": "Update model service models", "tags": [ "AI" ] @@ -32664,6 +32664,9 @@ }, "dto.AgentAccountCreateReq": { "properties": { + "accountType": { + "type": "string" + }, "apiKey": { "type": "string" }, @@ -32722,12 +32725,18 @@ }, "dto.AgentAccountInfo": { "properties": { + "accountType": { + "type": "string" + }, "apiKey": { "type": "string" }, "apiType": { "type": "string" }, + "appInstallId": { + "type": "integer" + }, "authMode": { "type": "string" }, @@ -32764,9 +32773,19 @@ "rememberApiKey": { "type": "boolean" }, + "validateAvailability": { + "type": "boolean" + }, "verified": { "type": "boolean" }, + "verifiedAt": { + "format": "date-time", + "type": "string" + }, + "verifyError": { + "type": "string" + }, "verifyModel": { "type": "string" } @@ -32819,25 +32838,33 @@ }, "dto.AgentAccountModelDiscoverReq": { "properties": { + "accountId": { + "description": "Existing account ID. When provided, connection settings are loaded from the saved account.", + "type": "integer" + }, + "accountType": { + "type": "string" + }, "apiKey": { + "description": "Required when accountId is not provided.", "type": "string" }, "apiType": { + "description": "Required when accountId is not provided.", + "type": "string" + }, + "authMode": { "type": "string" }, "baseURL": { + "description": "Required when accountId is not provided.", "type": "string" }, "provider": { + "description": "Required when accountId is not provided.", "type": "string" } }, - "required": [ - "apiKey", - "apiType", - "baseURL", - "provider" - ], "type": "object" }, "dto.AgentAccountModelReq": { @@ -32856,18 +32883,31 @@ "accountId": { "type": "integer" }, - "model": { - "$ref": "#/definitions/dto.AgentAccountModel" + "models": { + "type": "array", + "minItems": 1, + "items": { + "$ref": "#/definitions/dto.AgentAccountModel" + } + }, + "verifyModel": { + "type": "string" } }, "required": [ "accountId", - "model" + "models" ], "type": "object" }, "dto.AgentAccountProviderCountReq": { "properties": { + "excludeCodingPlanProviders": { + "items": { + "type": "string" + }, + "type": "array" + }, "providers": { "items": { "type": "string" @@ -32879,6 +32919,12 @@ }, "dto.AgentAccountSearch": { "properties": { + "excludeCodingPlanProviders": { + "items": { + "type": "string" + }, + "type": "array" + }, "apiType": { "type": "string" }, @@ -32906,6 +32952,9 @@ }, "dto.AgentAccountUpdateReq": { "properties": { + "accountType": { + "type": "string" + }, "apiKey": { "type": "string" }, @@ -32921,6 +32970,12 @@ "id": { "type": "integer" }, + "models": { + "items": { + "$ref": "#/definitions/dto.AgentAccountModel" + }, + "type": "array" + }, "name": { "type": "string" }, @@ -43051,8 +43106,28 @@ }, "type": "object" }, + "dto.ProviderAccountTypeInfo": { + "properties": { + "apiTypes": { + "items": { + "$ref": "#/definitions/dto.ProviderAPIInfo" + }, + "type": "array" + }, + "key": { + "type": "string" + } + }, + "type": "object" + }, "dto.ProviderInfo": { "properties": { + "accountTypes": { + "items": { + "$ref": "#/definitions/dto.ProviderAccountTypeInfo" + }, + "type": "array" + }, "apiTypes": { "items": { "$ref": "#/definitions/dto.ProviderAPIInfo" diff --git a/core/cmd/server/docs/x-log.json b/core/cmd/server/docs/x-log.json index f52e9699a..9b8d1d8d0 100644 --- a/core/cmd/server/docs/x-log.json +++ b/core/cmd/server/docs/x-log.json @@ -8,107 +8,6 @@ "formatZH": "更新 Ollama 绑定域名 [domain]", "formatEN": "update Ollama bind domain [domain]" }, - "/xpack/model/downloader/featured/sync/status": { - "bodyKeys": [ - "value" - ], - "paramKeys": [], - "beforeFunctions": [], - "formatZH": "更新推荐模型自动同步 [value]", - "formatEN": "update featured model automatic synchronization [value]" - }, - "/xpack/model/downloader/hf/download": { - "bodyKeys": [ - "repoID", - "revision" - ], - "paramKeys": [], - "beforeFunctions": [], - "formatZH": "下载 Hugging Face 模型 [repoID]", - "formatEN": "download Hugging Face model [repoID]" - }, - "/xpack/model/downloader/local/delete": { - "bodyKeys": [ - "name" - ], - "paramKeys": [], - "beforeFunctions": [], - "formatZH": "删除本地模型 [name]", - "formatEN": "delete local model [name]" - }, - "/xpack/model/downloader/modelscope/download": { - "bodyKeys": [ - "repoID", - "revision" - ], - "paramKeys": [], - "beforeFunctions": [], - "formatZH": "下载 ModelScope 模型 [repoID]", - "formatEN": "download ModelScope model [repoID]" - }, - "/xpack/model/downloader/settings": { - "bodyKeys": [ - "modelDir" - ], - "paramKeys": [], - "beforeFunctions": [], - "formatZH": "更新模型下载设置 [modelDir]", - "formatEN": "update model downloader settings [modelDir]" - }, - "/xpack/model/downloader/tasks/cancel": { - "bodyKeys": [ - "id" - ], - "paramKeys": [], - "beforeFunctions": [ - { - "input_column": "id", - "input_value": "id", - "isList": false, - "db": "model_download_tasks", - "output_column": "repo_id", - "output_value": "repoID" - } - ], - "formatZH": "取消模型下载任务 [repoID]", - "formatEN": "cancel model download task [repoID]" - }, - "/xpack/model/downloader/tasks/remove": { - "bodyKeys": [ - "id" - ], - "paramKeys": [], - "beforeFunctions": [ - { - "input_column": "id", - "input_value": "id", - "isList": false, - "db": "model_download_tasks", - "output_column": "repo_id", - "output_value": "repoID" - } - ], - "formatZH": "移除模型下载任务 [repoID]", - "formatEN": "remove model download task [repoID]" - }, - "/xpack/model/downloader/tasks/retry": { - "bodyKeys": [ - "id" - ], - "paramKeys": [], - "beforeFunctions": [ - { - "input_column": "id", - "input_value": "id", - "isList": false, - "db": "model_download_tasks", - "output_column": "repo_id", - "output_value": "repoID" - } - ], - "formatZH": "重试模型下载任务 [repoID]", - "formatEN": "retry model download task [repoID]" - }, "/ai/ollama/close": { "bodyKeys": [ "name" @@ -3815,6 +3714,25 @@ "formatZH": "[domain] PHP 配置修改", "formatEN": "[domain] PHP conf update" }, + "/runtimes/php/extensions/import": { + "bodyKeys": [ + "name" + ], + "paramKeys": [], + "beforeFunctions": [], + "formatZH": "同步 PHP 扩展模版 [name]", + "formatEN": "Sync PHP extension template [name]" + }, + "/runtimes/php/extensions/push": { + "bodyKeys": [ + "sourceNode", + "targetNodes" + ], + "paramKeys": [], + "beforeFunctions": [], + "formatZH": "推送 PHP 扩展模版 [sourceNode] 至 [targetNodes]", + "formatEN": "Push PHP extension template from [sourceNode] to [targetNodes]" + }, "/runtimes/php/update": { "bodyKeys": [ "websiteId" @@ -4211,6 +4129,282 @@ "formatZH": "扫描系统垃圾文件", "formatEN": "scan System Junk Files" }, + "/vms": { + "bodyKeys": [ + "name" + ], + "paramKeys": [], + "beforeFunctions": [], + "formatZH": "创建虚拟机 [name]", + "formatEN": "create VM [name]" + }, + "/vms/del": { + "bodyKeys": [ + "id" + ], + "paramKeys": [], + "beforeFunctions": [ + { + "input_column": "id", + "input_value": "id", + "isList": false, + "db": "virtual_machines", + "output_column": "name", + "output_value": "name" + } + ], + "formatZH": "删除虚拟机 [name]", + "formatEN": "delete VM [name]" + }, + "/vms/disks/resize": { + "bodyKeys": [ + "name", + "target", + "sizeGiB" + ], + "paramKeys": [], + "beforeFunctions": [], + "formatZH": "扩容虚拟机 [name] 磁盘 [target] 至 [sizeGiB] GiB", + "formatEN": "expand VM [name] disk [target] to [sizeGiB] GiB" + }, + "/vms/environment/enable": { + "bodyKeys": [], + "paramKeys": [], + "beforeFunctions": [], + "formatZH": "启用虚拟机运行环境", + "formatEN": "enable VM runtime environment" + }, + "/vms/iso": { + "bodyKeys": [ + "name", + "type" + ], + "paramKeys": [], + "beforeFunctions": [], + "formatZH": "创建虚拟机镜像 [name] [type]", + "formatEN": "create VM ISO [name] [type]" + }, + "/vms/iso/del": { + "bodyKeys": [ + "id" + ], + "paramKeys": [], + "beforeFunctions": [ + { + "input_column": "id", + "input_value": "id", + "isList": false, + "db": "vm_isos", + "output_column": "name", + "output_value": "name" + } + ], + "formatZH": "删除虚拟机镜像 [name]", + "formatEN": "delete VM ISO [name]" + }, + "/vms/iso/update": { + "bodyKeys": [ + "name", + "type" + ], + "paramKeys": [], + "beforeFunctions": [], + "formatZH": "更新虚拟机镜像 [name] [type]", + "formatEN": "update VM ISO [name] [type]" + }, + "/vms/networks": { + "bodyKeys": [ + "name", + "type" + ], + "paramKeys": [], + "beforeFunctions": [], + "formatZH": "创建虚拟机网络 [name] [type]", + "formatEN": "create VM network [name] [type]" + }, + "/vms/networks/del": { + "bodyKeys": [ + "id" + ], + "paramKeys": [], + "beforeFunctions": [ + { + "input_column": "id", + "input_value": "id", + "isList": false, + "db": "vm_networks", + "output_column": "name", + "output_value": "name" + } + ], + "formatZH": "删除虚拟机网络 [name]", + "formatEN": "delete VM network [name]" + }, + "/vms/networks/update": { + "bodyKeys": [ + "id" + ], + "paramKeys": [], + "beforeFunctions": [ + { + "input_column": "id", + "input_value": "id", + "isList": false, + "db": "vm_networks", + "output_column": "name", + "output_value": "name" + } + ], + "formatZH": "更新虚拟机网络 [name]", + "formatEN": "update VM network [name]" + }, + "/vms/operate": { + "bodyKeys": [ + "name", + "operate" + ], + "paramKeys": [], + "beforeFunctions": [], + "formatZH": "操作虚拟机 [name] [operate]", + "formatEN": "operate VM [name] [operate]" + }, + "/vms/orphans/clean": { + "bodyKeys": [], + "paramKeys": [], + "beforeFunctions": [], + "formatZH": "清理虚拟机孤立数据", + "formatEN": "clean VM orphaned data" + }, + "/vms/rename": { + "bodyKeys": [ + "name", + "newName" + ], + "paramKeys": [], + "beforeFunctions": [], + "formatZH": "重命名虚拟机 [name] 为 [newName]", + "formatEN": "rename VM [name] to [newName]" + }, + "/vms/snapshots": { + "bodyKeys": [ + "name", + "snapshotName" + ], + "paramKeys": [], + "beforeFunctions": [], + "formatZH": "创建虚拟机 [name] 快照 [snapshotName]", + "formatEN": "create VM [name] snapshot [snapshotName]" + }, + "/vms/snapshots/del": { + "bodyKeys": [ + "name", + "snapshotName" + ], + "paramKeys": [], + "beforeFunctions": [], + "formatZH": "删除虚拟机 [name] 快照 [snapshotName]", + "formatEN": "delete VM [name] snapshot [snapshotName]" + }, + "/vms/snapshots/recover": { + "bodyKeys": [ + "name", + "snapshotName" + ], + "paramKeys": [], + "beforeFunctions": [], + "formatZH": "恢复虚拟机 [name] 快照 [snapshotName]", + "formatEN": "recover VM [name] snapshot [snapshotName]" + }, + "/vms/storages": { + "bodyKeys": [ + "name", + "type" + ], + "paramKeys": [], + "beforeFunctions": [], + "formatZH": "创建虚拟机存储 [name] [type]", + "formatEN": "create VM storage [name] [type]" + }, + "/vms/storages/del": { + "bodyKeys": [ + "id" + ], + "paramKeys": [], + "beforeFunctions": [ + { + "input_column": "id", + "input_value": "id", + "isList": false, + "db": "vm_storages", + "output_column": "name", + "output_value": "name" + } + ], + "formatZH": "删除虚拟机存储 [name]", + "formatEN": "delete VM storage [name]" + }, + "/vms/storages/update": { + "bodyKeys": [ + "id" + ], + "paramKeys": [], + "beforeFunctions": [ + { + "input_column": "id", + "input_value": "id", + "isList": false, + "db": "vm_storages", + "output_column": "name", + "output_value": "name" + } + ], + "formatZH": "更新虚拟机存储 [name]", + "formatEN": "update VM storage [name]" + }, + "/vms/sync": { + "bodyKeys": [], + "paramKeys": [], + "beforeFunctions": [], + "formatZH": "同步虚拟机", + "formatEN": "sync virtual machines" + }, + "/vms/templates": { + "bodyKeys": [ + "name", + "templateName" + ], + "paramKeys": [], + "beforeFunctions": [], + "formatZH": "创建虚拟机 [name] 模板 [templateName]", + "formatEN": "create VM [name] template [templateName]" + }, + "/vms/templates/del": { + "bodyKeys": [ + "id" + ], + "paramKeys": [], + "beforeFunctions": [ + { + "input_column": "id", + "input_value": "id", + "isList": false, + "db": "vm_templates", + "output_column": "name", + "output_value": "name" + } + ], + "formatZH": "删除虚拟机模板 [name]", + "formatEN": "delete VM template [name]" + }, + "/vms/update": { + "bodyKeys": [ + "name" + ], + "paramKeys": [], + "beforeFunctions": [], + "formatZH": "更新虚拟机 [name]", + "formatEN": "update VM [name]" + }, "/websites": { "bodyKeys": [ "alias" @@ -5011,6 +5205,107 @@ "formatZH": "更新离线告警日志 [id]", "formatEN": "update offline alert log [id]" }, + "/xpack/model/downloader/featured/sync/status": { + "bodyKeys": [ + "value" + ], + "paramKeys": [], + "beforeFunctions": [], + "formatZH": "更新推荐模型自动同步 [value]", + "formatEN": "update featured model automatic synchronization [value]" + }, + "/xpack/model/downloader/hf/download": { + "bodyKeys": [ + "repoID", + "revision" + ], + "paramKeys": [], + "beforeFunctions": [], + "formatZH": "下载 Hugging Face 模型 [repoID]", + "formatEN": "download Hugging Face model [repoID]" + }, + "/xpack/model/downloader/local/delete": { + "bodyKeys": [ + "name" + ], + "paramKeys": [], + "beforeFunctions": [], + "formatZH": "删除本地模型 [name]", + "formatEN": "delete local model [name]" + }, + "/xpack/model/downloader/modelscope/download": { + "bodyKeys": [ + "repoID", + "revision" + ], + "paramKeys": [], + "beforeFunctions": [], + "formatZH": "下载 ModelScope 模型 [repoID]", + "formatEN": "download ModelScope model [repoID]" + }, + "/xpack/model/downloader/settings": { + "bodyKeys": [ + "modelDir" + ], + "paramKeys": [], + "beforeFunctions": [], + "formatZH": "更新模型下载设置 [modelDir]", + "formatEN": "update model downloader settings [modelDir]" + }, + "/xpack/model/downloader/tasks/cancel": { + "bodyKeys": [ + "id" + ], + "paramKeys": [], + "beforeFunctions": [ + { + "input_column": "id", + "input_value": "id", + "isList": false, + "db": "model_download_tasks", + "output_column": "repo_id", + "output_value": "repoID" + } + ], + "formatZH": "取消模型下载任务 [repoID]", + "formatEN": "cancel model download task [repoID]" + }, + "/xpack/model/downloader/tasks/remove": { + "bodyKeys": [ + "id" + ], + "paramKeys": [], + "beforeFunctions": [ + { + "input_column": "id", + "input_value": "id", + "isList": false, + "db": "model_download_tasks", + "output_column": "repo_id", + "output_value": "repoID" + } + ], + "formatZH": "移除模型下载任务 [repoID]", + "formatEN": "remove model download task [repoID]" + }, + "/xpack/model/downloader/tasks/retry": { + "bodyKeys": [ + "id" + ], + "paramKeys": [], + "beforeFunctions": [ + { + "input_column": "id", + "input_value": "id", + "isList": false, + "db": "model_download_tasks", + "output_column": "repo_id", + "output_value": "repoID" + } + ], + "formatZH": "重试模型下载任务 [repoID]", + "formatEN": "retry model download task [repoID]" + }, "/xpack/monitor/config/global": { "bodyKeys": [], "paramKeys": [], @@ -5130,6 +5425,17 @@ "formatZH": "创建 vLLM [name]", "formatEN": "create vLLM [name]" }, + "/xpack/vllm/monitor/setting/update": { + "bodyKeys": [ + "vllmID", + "key", + "value" + ], + "paramKeys": [], + "beforeFunctions": [], + "formatZH": "修改 vLLM [vllmID] 监控设置 [key]-[value]", + "formatEN": "update vLLM [vllmID] monitor setting [key]-[value]" + }, "/xpack/vllm/operate": { "bodyKeys": [ "id", @@ -5159,282 +5465,6 @@ "formatZH": "更新 vLLM [name]", "formatEN": "update vLLM [name]" }, - "/vms": { - "bodyKeys": [ - "name" - ], - "paramKeys": [], - "beforeFunctions": [], - "formatZH": "创建虚拟机 [name]", - "formatEN": "create VM [name]" - }, - "/vms/del": { - "bodyKeys": [ - "id" - ], - "paramKeys": [], - "beforeFunctions": [ - { - "input_column": "id", - "input_value": "id", - "isList": false, - "db": "virtual_machines", - "output_column": "name", - "output_value": "name" - } - ], - "formatZH": "删除虚拟机 [name]", - "formatEN": "delete VM [name]" - }, - "/vms/disks/resize": { - "bodyKeys": [ - "name", - "target", - "sizeGiB" - ], - "paramKeys": [], - "beforeFunctions": [], - "formatZH": "扩容虚拟机 [name] 磁盘 [target] 至 [sizeGiB] GiB", - "formatEN": "expand VM [name] disk [target] to [sizeGiB] GiB" - }, - "/vms/environment/enable": { - "bodyKeys": [], - "paramKeys": [], - "beforeFunctions": [], - "formatZH": "启用虚拟机运行环境", - "formatEN": "enable VM runtime environment" - }, - "/vms/iso": { - "bodyKeys": [ - "name", - "type" - ], - "paramKeys": [], - "beforeFunctions": [], - "formatZH": "创建虚拟机镜像 [name] [type]", - "formatEN": "create VM ISO [name] [type]" - }, - "/vms/iso/del": { - "bodyKeys": [ - "id" - ], - "paramKeys": [], - "beforeFunctions": [ - { - "input_column": "id", - "input_value": "id", - "isList": false, - "db": "vm_isos", - "output_column": "name", - "output_value": "name" - } - ], - "formatZH": "删除虚拟机镜像 [name]", - "formatEN": "delete VM ISO [name]" - }, - "/vms/iso/update": { - "bodyKeys": [ - "name", - "type" - ], - "paramKeys": [], - "beforeFunctions": [], - "formatZH": "更新虚拟机镜像 [name] [type]", - "formatEN": "update VM ISO [name] [type]" - }, - "/vms/networks": { - "bodyKeys": [ - "name", - "type" - ], - "paramKeys": [], - "beforeFunctions": [], - "formatZH": "创建虚拟机网络 [name] [type]", - "formatEN": "create VM network [name] [type]" - }, - "/vms/networks/del": { - "bodyKeys": [ - "id" - ], - "paramKeys": [], - "beforeFunctions": [ - { - "input_column": "id", - "input_value": "id", - "isList": false, - "db": "vm_networks", - "output_column": "name", - "output_value": "name" - } - ], - "formatZH": "删除虚拟机网络 [name]", - "formatEN": "delete VM network [name]" - }, - "/vms/networks/update": { - "bodyKeys": [ - "id" - ], - "paramKeys": [], - "beforeFunctions": [ - { - "input_column": "id", - "input_value": "id", - "isList": false, - "db": "vm_networks", - "output_column": "name", - "output_value": "name" - } - ], - "formatZH": "更新虚拟机网络 [name]", - "formatEN": "update VM network [name]" - }, - "/vms/operate": { - "bodyKeys": [ - "name", - "operate" - ], - "paramKeys": [], - "beforeFunctions": [], - "formatZH": "操作虚拟机 [name] [operate]", - "formatEN": "operate VM [name] [operate]" - }, - "/vms/orphans/clean": { - "bodyKeys": [], - "paramKeys": [], - "beforeFunctions": [], - "formatZH": "清理虚拟机孤立数据", - "formatEN": "clean VM orphaned data" - }, - "/vms/rename": { - "bodyKeys": [ - "name", - "newName" - ], - "paramKeys": [], - "beforeFunctions": [], - "formatZH": "重命名虚拟机 [name] 为 [newName]", - "formatEN": "rename VM [name] to [newName]" - }, - "/vms/snapshots": { - "bodyKeys": [ - "name", - "snapshotName" - ], - "paramKeys": [], - "beforeFunctions": [], - "formatZH": "创建虚拟机 [name] 快照 [snapshotName]", - "formatEN": "create VM [name] snapshot [snapshotName]" - }, - "/vms/snapshots/del": { - "bodyKeys": [ - "name", - "snapshotName" - ], - "paramKeys": [], - "beforeFunctions": [], - "formatZH": "删除虚拟机 [name] 快照 [snapshotName]", - "formatEN": "delete VM [name] snapshot [snapshotName]" - }, - "/vms/snapshots/recover": { - "bodyKeys": [ - "name", - "snapshotName" - ], - "paramKeys": [], - "beforeFunctions": [], - "formatZH": "恢复虚拟机 [name] 快照 [snapshotName]", - "formatEN": "recover VM [name] snapshot [snapshotName]" - }, - "/vms/storages": { - "bodyKeys": [ - "name", - "type" - ], - "paramKeys": [], - "beforeFunctions": [], - "formatZH": "创建虚拟机存储 [name] [type]", - "formatEN": "create VM storage [name] [type]" - }, - "/vms/storages/del": { - "bodyKeys": [ - "id" - ], - "paramKeys": [], - "beforeFunctions": [ - { - "input_column": "id", - "input_value": "id", - "isList": false, - "db": "vm_storages", - "output_column": "name", - "output_value": "name" - } - ], - "formatZH": "删除虚拟机存储 [name]", - "formatEN": "delete VM storage [name]" - }, - "/vms/storages/update": { - "bodyKeys": [ - "id" - ], - "paramKeys": [], - "beforeFunctions": [ - { - "input_column": "id", - "input_value": "id", - "isList": false, - "db": "vm_storages", - "output_column": "name", - "output_value": "name" - } - ], - "formatZH": "更新虚拟机存储 [name]", - "formatEN": "update VM storage [name]" - }, - "/vms/sync": { - "bodyKeys": [], - "paramKeys": [], - "beforeFunctions": [], - "formatZH": "同步虚拟机", - "formatEN": "sync virtual machines" - }, - "/vms/templates": { - "bodyKeys": [ - "name", - "templateName" - ], - "paramKeys": [], - "beforeFunctions": [], - "formatZH": "创建虚拟机 [name] 模板 [templateName]", - "formatEN": "create VM [name] template [templateName]" - }, - "/vms/templates/del": { - "bodyKeys": [ - "id" - ], - "paramKeys": [], - "beforeFunctions": [ - { - "input_column": "id", - "input_value": "id", - "isList": false, - "db": "vm_templates", - "output_column": "name", - "output_value": "name" - } - ], - "formatZH": "删除虚拟机模板 [name]", - "formatEN": "delete VM template [name]" - }, - "/vms/update": { - "bodyKeys": [ - "name" - ], - "paramKeys": [], - "beforeFunctions": [], - "formatZH": "更新虚拟机 [name]", - "formatEN": "update VM [name]" - }, "/xpack/waf/block/export": { "bodyKeys": [], "paramKeys": [], diff --git a/frontend/src/api/interface/ai.ts b/frontend/src/api/interface/ai.ts index 872d72a17..5de89c46e 100644 --- a/frontend/src/api/interface/ai.ts +++ b/frontend/src/api/interface/ai.ts @@ -678,10 +678,13 @@ export namespace AI { } export interface AgentAccountModelDiscoverReq { - provider: string; - baseURL: string; - apiKey: string; - apiType: string; + accountId?: number; + accountType?: string; + provider?: string; + baseURL?: string; + apiKey?: string; + apiType?: string; + authMode?: string; } export interface AgentAccountModelCreateReq { @@ -692,7 +695,8 @@ export namespace AI { export interface AgentAccountModelUpdateReq { accountId: number; - model: AgentAccountModel; + models: AgentAccountModel[]; + verifyModel: string; } export interface AgentAccountModelDeleteReq { @@ -716,7 +720,13 @@ export namespace AI { models: ProviderModelInfo[]; } + export interface ProviderAccountType { + key: string; + apiTypes: ProviderAPIInfo[]; + } + export interface ProviderInfo { + accountTypes: ProviderAccountType[]; provider: string; displayName: string; baseUrl: string; @@ -726,6 +736,7 @@ export namespace AI { } export interface AgentAccountCreateReq { + accountType?: string; provider: string; name: string; apiKey: string; @@ -740,6 +751,7 @@ export namespace AI { } export interface AgentAccountUpdateReq { + accountType?: string; id: number; name: string; apiKey: string; @@ -755,6 +767,7 @@ export namespace AI { } export interface AgentAccountSearch { + excludeCodingPlanProviders?: string[]; page: number; pageSize: number; provider: string; @@ -764,10 +777,12 @@ export namespace AI { } export interface AgentAccountProviderCountReq { + excludeCodingPlanProviders?: string[]; providers: string[]; } export interface AgentAccountItem { + accountType?: string; appInstallId?: number; id: number; provider: string; diff --git a/frontend/src/api/modules/ai.ts b/frontend/src/api/modules/ai.ts index b72d098cc..ef9f60274 100644 --- a/frontend/src/api/modules/ai.ts +++ b/frontend/src/api/modules/ai.ts @@ -251,7 +251,10 @@ export const updateAgentAccountVerifyModel = (req: AI.AgentAccountVerifyModelUpd }; export const discoverAgentAccountModels = (req: AI.AgentAccountModelDiscoverReq) => { - return http.post(`/ai/accounts/models/discover`, req); + return http.postWithConfig(`/ai/accounts/models/discover`, req, { + timeout: TimeoutEnum.T_60S, + errorMessageMode: 'manual', + }); }; export const createAgentAccountModel = (req: AI.AgentAccountModelCreateReq) => { diff --git a/frontend/src/assets/images/ai-providers/deepseek.png b/frontend/src/assets/images/ai-providers/deepseek.png deleted file mode 100644 index aadbb5813cfd04a54b7415ca78b8306a3e850603..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 908 zcmV;719SX|P)Px#1ZP1_K>z@;j|==^1poj5OHfQyMMrQ-3cI2QT2_{nE}V%Y`X;6%;T{D00O*8L_t(I%dJ&evfMBT zl+eDfwz>aF1GeWSf2pKKRb$y8(NfbeLfm7VG?cV%2yt#DzC5IbY%+xDJH>V-OSY=? zrSQYa8qCYu+@E_UO$Gge;;(hrIKnQZ<{2}VFl%_-%bk|Cwy zr}`L_l+Rg}RPW3h>1cWNpp+i9>gJ#LWffc|BldVc0*H_pz=APAXOhvF?1m!IZ4;#! zE|bCjIM{GI`eo@oS}`#bsLgdTRV(a<#b5aH563)WK(Fh+%?!5JIDVpE zhO7V~hOnAkJ%yk#_RHy;2P!N3CZ5lZ+AzRdWA>J6Wq=WC?U2!Bnu9Hx5(HN~bJffl zBa@>_x*g5k{QxA7{ZrD0)l}%=Uj-?q8x~WvT@2c~LW~%lQ_&LgY|`{>ZN-p0IkGlG zGk3i!qR3896pe~J(F-Y|KQ)2jQ(0!UNqxlGV@>WXH# zFx%Rvc~)cy zISEsfP`mOKGD)ALx(kWSv6PzqqZ3kHDXyqbJw1hHFFn-rO%BBwJKuRcE8k6AdukW- zJqM&ND&wTiH-r3JgRkZv+6FZrDlV2#nVmF2MfA7kb4vLyjY-As@0Lx6H_19@&oBR_ i4do2ww^Wed4*d&kJ^s_0000 + + diff --git a/frontend/src/assets/images/ai-providers/kimi.png b/frontend/src/assets/images/ai-providers/kimi.png new file mode 100644 index 0000000000000000000000000000000000000000..cf7d9334fb317fbceceeb92233f2386b80abc867 GIT binary patch literal 4542 zcmYLN2Q=J4xBssay$fR15G8s9Ay`&fT@ZCe3yEHXT`a4&=tA^FB5FhnA$sp(MX%8l zy+>Kz=DqKHZ_c^%yL0E>nR9;U&b{YM^b;Kz1t~Kr000!~YRdXJRQM;vw{UZbgU136 z2wo~`D*`}e0@;-{A#Tm_Tuoma0Q`6W038MZ7dR7o69BwL0pO1n0LZ)r07m!h20dBa z2Exun{e`wRa37}=0|X#u;NJ-#oXCT~|J7ANd;tFc+VKD&(g7g&kB<%x{|z;q{EPWN z#D53+k2lWt4)4F-3h(g$U;h{8z2Fmx0}^*NQ!fA@qx&ZyATyf@0H`a}l@*^NK=ZRs zuZ_n2i1sBqTBAbpJIRrikCp3uu$u1hm zFOO-+KMGK1VT9eA+`wR9>gXWw$zV~WGAsC`5RXv_%T1`B2g_kRsVt&WQRzkZpN?L# ze_;ML(|^z%tl1aq;9}jit3+B|xWLrH zaRf>2P+GCa*`)2ct8Gn9jR~ifvl+MSof>$d<$$-7lT*R1+ z#@@^mBZ!g`W;)(>YaiC7sc$CCC&ms~V396en|`o(TsO5P%F+0&R6x+O%yM|;(Svr- z`Yn(T0`B4fhDd*9|C{ww@}gB+G;E+S4lMP8mJ~EoJN+U{d}Rv5Ah$iu>w@tTu(!V> z`;a2<`tsqcL(9UnHkV?vOOzRQF6g77_zhMwR`~uP2YYkrOwXf71FH5Hqfl)RUp0sXymZft#01OVZOmz$++Ac znZP0{{3kKu*yt5T{$M+GBC=gS8-sL)w0gl|APWa4C(Y1X6#d@Vi<5SnUa7?ZaY_)} z<=k8c@nC2}fZA}GL^jl3XvQV^Gna$Wl(<%$nKo1)dM?>-J6kE$ofg>ky$xm^Mf;y$S=Y=({ZG(PwEN73mE0p9heI-8@ z7IJxXvfozTc=hlhnUt_ae!KM>xBBJ>8j(jOQQrgOeCIrR3@rl=RL+7Ojg#uZD-<&x zUmSad4NBTp3ZJ^HP<}Rx-2M4&k{rfVpkKEbco{$rwbl)Chj>}~XOmaLKU$Ox3k{Yt;n{RZ%aN3zMcrC zcE_mm8q#D*^gb(W#Zfe#wK$(cBR(&Zk-)5`i|*mHT>evGwKq;IqfEYb6bTN=mEN{PFmX7?;)> zrjrJvXt=5dCik4SSk7)D&||ugCbLQ#6$;Nu{(WO}50#D`e=Y?kwHN3Up6Z?2S)+x~df@K|3vvKrgdBy3uWn?%^y7iEUsRMG4}l0%6`}>y8M+O4CxC zqZB(bq)$kTNrpViuVJtG60`p+xAi+C{HMT|#s~ArjhuP6W6#??EDSq)IFp@7 z0>yxcSQ3pso4u)P^9h*=MVnW%Ob1U0-D|5Jk^dgkGm=^Do74Tl!MpEXI=LDV!`ekx z)&8UO9p44y1`Bi3YHV<*l&LtLMG*Fc+|g@kvdq-r*{e|%iv85`(9HyE4Zh747Ean{ z2y-^eWr6eelDi`?^vhr}k;V$+furDDl7wZ!@v%&aaIo$8?6Fr|W7YVZb1J#x9~xIj z1SF$!p2MtilsC?6t@u=0XAAyrq=bGsT#`_JdY3uIk;CAPlcmDZ=7N-DqTb&E>;acM zb<(F?ou2T-AH8IUPs)hn((~cWH?VoCQs>G=LPqn%T-50_eO7*ia}Zie#yfX27QG)v zuZzkchPkM)+oI0qeb2jk(0?I)iyFw0c-Zpy?={cYj?)2eBN@t6xSwM0hbpS|LlF0YSoVe{aopqHgM8 z^Z$rFofSb{9rUzh6V2gXJpY40zwOE%%s~%(o|JNvb@V*EVXOQ*hShg2>GOEj-1^Kt zOfnOWti8rN$>hke!{u0!PY8y-4Wx8bHHbB92fv-rD|+4%d9^LsBQa@ipz=xBMmyn@ zwui+_t1b{VI_|j__iSivk!)IZQqNqQ`g_u-+gR0oH(~D7Bhk^=cA@gsdT`OMALtUYj z4fb_jXM!yU@*Msl+)Px;>g{nu#%v>1MaNmsP|lBjR#iK$gZ5f(0u2VvvQrA$=d=72 znnvkXaYaR7kEVZs>iKQf7 z^<&JfTQmi4q0l98mJC1k<^Y7(M&q`vfT0Ct$%q+eRN2Q;t~^qwL!-N-DzGkgIpqP;3`DiexmBH06dGGWUnj z=|2A3V>*w82HxcT?R+C8k1Mg22vE3`F>w0qW+{|vxaXc`nyqod8_q3W`g(}w?0FL| zw@u^g0{;GrRDTrZ|FP>&svO^|>-040>shPqMUW7~do|8BBS1 zA)4udC-qx$y-A7{?WH#7{oR>z{ysi-okeUu)b|Qaf^Gc{Wy1#8y?^SR6KBcNSh%A$ ze>9lg6{F!$5$n;{0EdHowE4eMTKE?ixJf&HVMLMrZVFESE#zR6Rvr)+S3B#PLGa*J z1aEDpPo97omuni$6AD)at!UnD{SYun#k#e>$;PDz3YB&oo75Y1eeLW}tR{@)L+E=^WY*&wjbyq2RRLhyv-+i#kk;5&_ zAy$A-NTI+P#z*hfQj@-_J`Dws;aaRUTYj8{RMZ7bu1gU+upEUGEv zzvG#}?5@LHHnUlmOtUj?Y!UGulY|jLF7>}6z!5!TGgnsLQuv&Tb5EdZn@=ZR_A>)k z+#c13iAt*MoqVa>N^FTxljb`R!dJSUg3-jn>LXwKU52a^tOAuwWT62)ijL9UNT zvQQ)dWvd#rOF+NbXhJ?)+33j|lx1TV!~c4dn`#f&OZA_k-s8q+aw|^V>X8 zYv}GC6UlyMYqOZ!Qs^3_yUP>*$x|r5I?qDs1_eQDS(`p^8Oq17l-vk|kb*W&=(_mv znf88x%1Wv-FBOW@1Q>)|on^h;4a;K_X&nU{?ML&S?VkVWnOc{OaAIqJ(k;f`!7m#s zJX$LlfAjfs0NC7fSbF1X<6qChcQPk2!Jn49qo5^swcqhO)j+3Di>vccNso@-)--Y8 z+)22fKDI)ml1G{Wn&~r+xJZJbkC~kuqfiG@3{5TVnefjgp`>yM;dvSz#+Bq) z=|J{9qAMi0_)fN~+t+_#-}78md__vT z@YX(PZCjfSGCVW4$usEJSog`8!!nEQ4^)CTJ+octd%LMm#9jq(5jicoV1=AOI>zo zJ|V1`^Ah9-=TX}8wr*eKG}-? zyFjc^bOMW&`CHm@A&7ad@wXncRu98|&bLlx!N%7z358pV%m zyl#MrY1~!j`}=n(GeqHlIk(N5CO>YLj58({o~G;^X2YhNtVFF35*JQhB}XAX9()y# z$fpV!qC+hbKgSw!?_a@^Oy8Z3r2=QqN3QyW>gEn3O{-sgj(#mGM$i5tlK5c-k65u2 zDX7zi=X9_<>N!WftNKU5LUvPIcVwFZ zlU7(aW=kaGDu|5g`(eh*T+_tcj)!BIk1i>n?ufs5opA54&U#0@qal)DsuEO##WhjQ zQ - - - diff --git a/frontend/src/assets/images/ai-providers/opencode.svg b/frontend/src/assets/images/ai-providers/opencode.svg new file mode 100644 index 000000000..e9b0aba5c --- /dev/null +++ b/frontend/src/assets/images/ai-providers/opencode.svg @@ -0,0 +1 @@ +OpenCode diff --git a/frontend/src/assets/images/ai-providers/qianfan.svg b/frontend/src/assets/images/ai-providers/qianfan.svg new file mode 100644 index 000000000..c9b52cc28 --- /dev/null +++ b/frontend/src/assets/images/ai-providers/qianfan.svg @@ -0,0 +1 @@ +Baidu Qianfan diff --git a/frontend/src/assets/images/ai-providers/siliconflow.svg b/frontend/src/assets/images/ai-providers/siliconflow.svg new file mode 100644 index 000000000..a8ebf16f0 --- /dev/null +++ b/frontend/src/assets/images/ai-providers/siliconflow.svg @@ -0,0 +1 @@ +SiliconFlow diff --git a/frontend/src/assets/images/ai-providers/tencentcloud.svg b/frontend/src/assets/images/ai-providers/tencentcloud.svg new file mode 100644 index 000000000..3af0f5675 --- /dev/null +++ b/frontend/src/assets/images/ai-providers/tencentcloud.svg @@ -0,0 +1 @@ +Tencent Cloud diff --git a/frontend/src/lang/modules/en.ts b/frontend/src/lang/modules/en.ts index b3ac20aea..7e3e4f9a3 100644 --- a/frontend/src/lang/modules/en.ts +++ b/frontend/src/lang/modules/en.ts @@ -1119,6 +1119,33 @@ const message = { validateImageAvailabilityHelper: 'Generates one minimal image before saving and may incur charges', }, model: { + poolEditHelp: 'Fetch online or add manually. Every model in this list is editable.', + poolUnavailable: 'Online discovery is unavailable for this provider type and API. Add model IDs manually.', + poolEmpty: 'No models yet. Fetch online or add a model manually.', + poolOverwrite: + 'A successful fetch will replace the entire list, including manual additions and edits. Continue?', + poolFetchEmpty: 'No models returned. Your list is unchanged. Retry or add models manually.', + poolFetchFailed: + 'Fetch failed. Your list is unchanged. Check the URL, API key and network, then retry or edit manually.', + poolSaveHelp: 'Changes take effect when saved. Models currently in use cannot be removed.', + + accountType: 'Account type', + accountTypes: { + default: 'Default', + payAsYouGo: 'Pay as you go', + chinaApi: 'China API', + globalApi: 'Global API', + chinaCodingPlan: 'China Coding Plan', + globalCodingPlan: 'Global Coding Plan', + chinaTokenPlan: 'China Token Plan', + globalTokenPlan: 'Global Token Plan', + speech: 'Speech services', + codingPlan: 'Coding Plan', + tokenPlan: 'Token Plan', + agentPlan: 'Agent Plan', + go: 'Go', + zen: 'Zen', + }, externalInspect: 'Check and fetch', externalHealthPassed: 'Health check passed', externalHealthFailed: 'Health check failed', diff --git a/frontend/src/lang/modules/es-es.ts b/frontend/src/lang/modules/es-es.ts index 1b1826fa5..730ec8f88 100644 --- a/frontend/src/lang/modules/es-es.ts +++ b/frontend/src/lang/modules/es-es.ts @@ -1121,6 +1121,34 @@ const message = { validateImageAvailabilityHelper: 'Genera una imagen mínima antes de guardar y puede generar costes', }, model: { + poolEditHelp: 'Obtenga modelos en línea o añádalos manualmente. Todos se pueden editar.', + poolUnavailable: + 'Este tipo de proveedor y API no permite obtener modelos en línea. Añada los ID manualmente.', + poolEmpty: 'No hay modelos. Obténgalos en línea o añádalos manualmente.', + poolOverwrite: + 'Si la consulta tiene éxito, se reemplazará toda la lista, incluidas las adiciones y ediciones manuales. ¿Continuar?', + poolFetchEmpty: 'No se recibieron modelos. La lista se conserva. Reintente o añádalos manualmente.', + poolFetchFailed: + 'Error al obtener modelos. La lista se conserva. Revise la URL, la clave API y la red, o edite manualmente.', + poolSaveHelp: 'Los cambios se aplican al guardar. No se pueden quitar modelos en uso.', + + accountType: 'Tipo de cuenta', + accountTypes: { + default: 'Predeterminado', + payAsYouGo: 'Pago por uso', + chinaApi: 'API de China', + globalApi: 'API global', + chinaCodingPlan: 'Coding Plan de China', + globalCodingPlan: 'Coding Plan global', + chinaTokenPlan: 'Token Plan de China', + globalTokenPlan: 'Token Plan global', + speech: 'Servicios de voz', + codingPlan: 'Coding Plan', + tokenPlan: 'Token Plan', + agentPlan: 'Agent Plan', + go: 'Go', + zen: 'Zen', + }, externalInspect: 'Comprobar y obtener', externalHealthPassed: 'Comprobación de salud correcta', externalHealthFailed: 'Falló la comprobación de salud', diff --git a/frontend/src/lang/modules/fa.ts b/frontend/src/lang/modules/fa.ts index 17961e165..5ba12c613 100644 --- a/frontend/src/lang/modules/fa.ts +++ b/frontend/src/lang/modules/fa.ts @@ -1103,6 +1103,34 @@ const message = { validateImageAvailabilityHelper: 'پیش از ذخیره یک تصویر حداقلی تولید می‌شود و ممکن است هزینه داشته باشد', }, model: { + poolEditHelp: 'مدل‌ها را آنلاین دریافت یا دستی اضافه کنید. همه مدل‌ها قابل ویرایش هستند.', + poolUnavailable: + 'این نوع ارائه‌دهنده و API از دریافت آنلاین پشتیبانی نمی‌کند. شناسه مدل‌ها را دستی اضافه کنید.', + poolEmpty: 'مدلی وجود ندارد. آنلاین دریافت یا دستی اضافه کنید.', + poolOverwrite: + 'دریافت موفق، کل فهرست از جمله موارد افزوده یا ویرایش‌شده دستی را جایگزین می‌کند. ادامه می‌دهید؟', + poolFetchEmpty: 'مدلی دریافت نشد. فهرست فعلی حفظ شد. دوباره تلاش کنید یا دستی اضافه کنید.', + poolFetchFailed: + 'دریافت ناموفق بود. فهرست حفظ شد. نشانی، کلید API و شبکه را بررسی کنید یا دستی ویرایش کنید.', + poolSaveHelp: 'تغییرات پس از ذخیره اعمال می‌شوند. مدل‌های در حال استفاده قابل حذف نیستند.', + + accountType: 'نوع حساب', + accountTypes: { + default: 'پیش‌فرض', + payAsYouGo: 'پرداخت بر اساس مصرف', + chinaApi: 'API چین', + globalApi: 'API جهانی', + chinaCodingPlan: 'Coding Plan چین', + globalCodingPlan: 'Coding Plan جهانی', + chinaTokenPlan: 'Token Plan چین', + globalTokenPlan: 'Token Plan جهانی', + speech: 'خدمات گفتار', + codingPlan: 'Coding Plan', + tokenPlan: 'Token Plan', + agentPlan: 'Agent Plan', + go: 'Go', + zen: 'Zen', + }, externalInspect: 'بررسی و دریافت', externalHealthPassed: 'بررسی سلامت موفق بود', externalHealthFailed: 'بررسی سلامت ناموفق بود', diff --git a/frontend/src/lang/modules/ja.ts b/frontend/src/lang/modules/ja.ts index 6f8be424b..f9cf8af67 100644 --- a/frontend/src/lang/modules/ja.ts +++ b/frontend/src/lang/modules/ja.ts @@ -1104,6 +1104,33 @@ const message = { validateImageAvailabilityHelper: '保存前に最小画像を1枚生成するため、料金が発生する場合があります', }, model: { + poolEditHelp: 'オンラインで取得するか手動で追加できます。すべてのモデルを編集できます。', + poolUnavailable: + 'このプロバイダー種別と API はオンライン取得に対応していません。モデル ID を手動で追加してください。', + poolEmpty: 'モデルがありません。オンラインで取得するか手動で追加してください。', + poolOverwrite: '取得に成功すると、手動で追加・編集した内容を含む一覧全体が置き換わります。続行しますか?', + poolFetchEmpty: 'モデルが返されませんでした。一覧は保持されています。再試行するか手動で追加してください。', + poolFetchFailed: + '取得に失敗しました。一覧は保持されています。URL、API キー、ネットワークを確認して再試行するか、手動で編集してください。', + poolSaveHelp: '保存後に反映されます。使用中のモデルは削除できません。', + + accountType: 'アカウント種別', + accountTypes: { + default: '既定', + payAsYouGo: '従量課金', + chinaApi: '中国 API', + globalApi: '国際 API', + chinaCodingPlan: '中国 Coding Plan', + globalCodingPlan: '国際 Coding Plan', + chinaTokenPlan: '中国 Token Plan', + globalTokenPlan: '国際 Token Plan', + speech: '音声サービス', + codingPlan: 'Coding Plan', + tokenPlan: 'Token Plan', + agentPlan: 'Agent Plan', + go: 'Go', + zen: 'Zen', + }, externalInspect: '確認して取得', externalHealthPassed: 'ヘルスチェック成功', externalHealthFailed: 'ヘルスチェック失敗', diff --git a/frontend/src/lang/modules/ko.ts b/frontend/src/lang/modules/ko.ts index 980eb3faa..7ca021ed0 100644 --- a/frontend/src/lang/modules/ko.ts +++ b/frontend/src/lang/modules/ko.ts @@ -1096,6 +1096,32 @@ const message = { validateImageAvailabilityHelper: '저장 전에 최소 이미지 한 장을 생성하며 비용이 발생할 수 있습니다', }, model: { + poolEditHelp: '온라인으로 가져오거나 직접 추가하세요. 모든 모델을 수정할 수 있습니다.', + poolUnavailable: '이 공급자 유형과 API는 온라인 가져오기를 지원하지 않습니다. 모델 ID를 직접 추가하세요.', + poolEmpty: '모델이 없습니다. 온라인으로 가져오거나 직접 추가하세요.', + poolOverwrite: '가져오기에 성공하면 수동 추가 및 수정 사항을 포함한 전체 목록이 교체됩니다. 계속할까요?', + poolFetchEmpty: '모델이 반환되지 않았습니다. 기존 목록은 유지됩니다. 다시 시도하거나 직접 추가하세요.', + poolFetchFailed: + '가져오기에 실패했습니다. 기존 목록은 유지됩니다. URL, API 키, 네트워크를 확인한 후 다시 시도하거나 직접 수정하세요.', + poolSaveHelp: '저장 후 적용됩니다. 사용 중인 모델은 삭제할 수 없습니다.', + + accountType: '계정 유형', + accountTypes: { + default: '기본', + payAsYouGo: '종량제', + chinaApi: '중국 API', + globalApi: '글로벌 API', + chinaCodingPlan: '중국 Coding Plan', + globalCodingPlan: '글로벌 Coding Plan', + chinaTokenPlan: '중국 Token Plan', + globalTokenPlan: '글로벌 Token Plan', + speech: '음성 서비스', + codingPlan: 'Coding Plan', + tokenPlan: 'Token Plan', + agentPlan: 'Agent Plan', + go: 'Go', + zen: 'Zen', + }, externalInspect: '확인 및 가져오기', externalHealthPassed: '상태 확인 성공', externalHealthFailed: '상태 확인 실패', diff --git a/frontend/src/lang/modules/lo.ts b/frontend/src/lang/modules/lo.ts index 6b1a2120e..a84d6bc67 100644 --- a/frontend/src/lang/modules/lo.ts +++ b/frontend/src/lang/modules/lo.ts @@ -1091,6 +1091,31 @@ const message = { validateImageAvailabilityHelper: 'ສ້າງຮູບຂະໜາດນ້ອຍໜຶ່ງຮູບກ່ອນບັນທຶກ ແລະ ອາດມີຄ່າໃຊ້ຈ່າຍ', }, model: { + poolEditHelp: 'ດຶງແບບຈຳລອງອອນລາຍ ຫຼື ເພີ່ມເອງ. ທຸກລາຍການສາມາດແກ້ໄຂໄດ້.', + poolUnavailable: 'ປະເພດຜູ້ໃຫ້ບໍລິການ ແລະ API ນີ້ບໍ່ຮອງຮັບການດຶງອອນລາຍ. ກະລຸນາເພີ່ມ ID ເອງ.', + poolEmpty: 'ຍັງບໍ່ມີແບບຈຳລອງ. ດຶງອອນລາຍ ຫຼື ເພີ່ມເອງ.', + poolOverwrite: 'ເມື່ອດຶງສຳເລັດ ລາຍການທັງໝົດລວມທັງທີ່ເພີ່ມ ແລະ ແກ້ໄຂເອງຈະຖືກແທນທີ່. ສືບຕໍ່ບໍ?', + poolFetchEmpty: 'ບໍ່ພົບແບບຈຳລອງ. ລາຍການເດີມຍັງຢູ່. ລອງໃໝ່ ຫຼື ເພີ່ມເອງ.', + poolFetchFailed: 'ດຶງບໍ່ສຳເລັດ. ລາຍການເດີມຍັງຢູ່. ກວດ URL, API Key ແລະ ເຄືອຂ່າຍ ຫຼື ແກ້ໄຂເອງ.', + poolSaveHelp: 'ການປ່ຽນແປງມີຜົນຫຼັງບັນທຶກ. ບໍ່ສາມາດລຶບແບບຈຳລອງທີ່ກຳລັງໃຊ້.', + + accountType: 'ປະເພດບັນຊີ', + accountTypes: { + default: 'ເລີ່ມຕົ້ນ', + payAsYouGo: 'ຈ່າຍຕາມການໃຊ້', + chinaApi: 'API ຈີນ', + globalApi: 'API ສາກົນ', + chinaCodingPlan: 'Coding Plan ຈີນ', + globalCodingPlan: 'Coding Plan ສາກົນ', + chinaTokenPlan: 'Token Plan ຈີນ', + globalTokenPlan: 'Token Plan ສາກົນ', + speech: 'ບໍລິການສຽງ', + codingPlan: 'Coding Plan', + tokenPlan: 'Token Plan', + agentPlan: 'Agent Plan', + go: 'Go', + zen: 'Zen', + }, externalInspect: 'ກວດສອບ ແລະ ດຶງຂໍ້ມູນ', externalHealthPassed: 'ກວດສອບສະຖານະຜ່ານ', externalHealthFailed: 'ກວດສອບສະຖານະບໍ່ຜ່ານ', diff --git a/frontend/src/lang/modules/ms.ts b/frontend/src/lang/modules/ms.ts index 76609d8a8..728e9e629 100644 --- a/frontend/src/lang/modules/ms.ts +++ b/frontend/src/lang/modules/ms.ts @@ -1130,6 +1130,34 @@ const message = { validateImageAvailabilityHelper: 'Menjana satu imej minimum sebelum menyimpan dan mungkin dikenakan caj', }, model: { + poolEditHelp: 'Dapatkan model dalam talian atau tambah secara manual. Semua model boleh disunting.', + poolUnavailable: + 'Jenis pembekal dan API ini tidak menyokong pengambilan dalam talian. Tambah ID model secara manual.', + poolEmpty: 'Tiada model. Dapatkan dalam talian atau tambah secara manual.', + poolOverwrite: + 'Pengambilan yang berjaya akan menggantikan seluruh senarai, termasuk tambahan dan suntingan manual. Teruskan?', + poolFetchEmpty: 'Tiada model diterima. Senarai dikekalkan. Cuba lagi atau tambah secara manual.', + poolFetchFailed: + 'Pengambilan gagal. Senarai dikekalkan. Semak URL, kunci API dan rangkaian atau sunting secara manual.', + poolSaveHelp: 'Perubahan berkuat kuasa selepas disimpan. Model yang sedang digunakan tidak boleh dibuang.', + + accountType: 'Jenis akaun', + accountTypes: { + default: 'Lalai', + payAsYouGo: 'Bayar mengikut penggunaan', + chinaApi: 'API China', + globalApi: 'API global', + chinaCodingPlan: 'Coding Plan China', + globalCodingPlan: 'Coding Plan global', + chinaTokenPlan: 'Token Plan China', + globalTokenPlan: 'Token Plan global', + speech: 'Perkhidmatan suara', + codingPlan: 'Coding Plan', + tokenPlan: 'Token Plan', + agentPlan: 'Agent Plan', + go: 'Go', + zen: 'Zen', + }, externalInspect: 'Semak dan dapatkan', externalHealthPassed: 'Semakan kesihatan berjaya', externalHealthFailed: 'Semakan kesihatan gagal', diff --git a/frontend/src/lang/modules/pt-br.ts b/frontend/src/lang/modules/pt-br.ts index 0e77b48b2..c3620ab87 100644 --- a/frontend/src/lang/modules/pt-br.ts +++ b/frontend/src/lang/modules/pt-br.ts @@ -1125,6 +1125,34 @@ const message = { validateImageAvailabilityHelper: 'Gera uma imagem mínima antes de salvar e pode gerar custos', }, model: { + poolEditHelp: 'Busque modelos online ou adicione manualmente. Todos podem ser editados.', + poolUnavailable: + 'Este tipo de provedor e API não permite buscar modelos online. Adicione os IDs manualmente.', + poolEmpty: 'Nenhum modelo. Busque online ou adicione manualmente.', + poolOverwrite: + 'Uma busca bem-sucedida substituirá toda a lista, incluindo adições e edições manuais. Continuar?', + poolFetchEmpty: 'Nenhum modelo retornado. A lista foi mantida. Tente novamente ou adicione manualmente.', + poolFetchFailed: + 'Falha na busca. A lista foi mantida. Verifique a URL, a chave API e a rede ou edite manualmente.', + poolSaveHelp: 'As alterações entram em vigor ao salvar. Modelos em uso não podem ser removidos.', + + accountType: 'Tipo de conta', + accountTypes: { + default: 'Padrão', + payAsYouGo: 'Pagamento por uso', + chinaApi: 'API da China', + globalApi: 'API global', + chinaCodingPlan: 'Coding Plan da China', + globalCodingPlan: 'Coding Plan global', + chinaTokenPlan: 'Token Plan da China', + globalTokenPlan: 'Token Plan global', + speech: 'Serviços de voz', + codingPlan: 'Coding Plan', + tokenPlan: 'Token Plan', + agentPlan: 'Agent Plan', + go: 'Go', + zen: 'Zen', + }, externalInspect: 'Verificar e obter', externalHealthPassed: 'Verificação de integridade aprovada', externalHealthFailed: 'Falha na verificação de integridade', diff --git a/frontend/src/lang/modules/ru.ts b/frontend/src/lang/modules/ru.ts index 872d636bf..c085a30ac 100644 --- a/frontend/src/lang/modules/ru.ts +++ b/frontend/src/lang/modules/ru.ts @@ -1118,6 +1118,33 @@ const message = { 'Перед сохранением создаётся одно минимальное изображение; возможна оплата', }, model: { + poolEditHelp: 'Загрузите модели онлайн или добавьте вручную. Все модели можно редактировать.', + poolUnavailable: + 'Этот тип провайдера и API не поддерживает загрузку списка онлайн. Добавьте ID моделей вручную.', + poolEmpty: 'Моделей нет. Загрузите список онлайн или добавьте модели вручную.', + poolOverwrite: 'Успешная загрузка заменит весь список, включая ручные добавления и изменения. Продолжить?', + poolFetchEmpty: 'Модели не получены. Список сохранён. Повторите попытку или добавьте модели вручную.', + poolFetchFailed: + 'Ошибка загрузки. Список сохранён. Проверьте URL, ключ API и сеть или отредактируйте список вручную.', + poolSaveHelp: 'Изменения применяются после сохранения. Используемые модели удалить нельзя.', + + accountType: 'Тип аккаунта', + accountTypes: { + default: 'По умолчанию', + payAsYouGo: 'Оплата по использованию', + chinaApi: 'API Китая', + globalApi: 'Международный API', + chinaCodingPlan: 'Coding Plan Китая', + globalCodingPlan: 'Международный Coding Plan', + chinaTokenPlan: 'Token Plan Китая', + globalTokenPlan: 'Международный Token Plan', + speech: 'Речевые сервисы', + codingPlan: 'Coding Plan', + tokenPlan: 'Token Plan', + agentPlan: 'Agent Plan', + go: 'Go', + zen: 'Zen', + }, externalInspect: 'Проверить и получить', externalHealthPassed: 'Проверка работоспособности пройдена', externalHealthFailed: 'Проверка работоспособности не пройдена', diff --git a/frontend/src/lang/modules/tr.ts b/frontend/src/lang/modules/tr.ts index 6fbb49a9d..1a3b1e6b4 100644 --- a/frontend/src/lang/modules/tr.ts +++ b/frontend/src/lang/modules/tr.ts @@ -1128,6 +1128,34 @@ const message = { validateImageAvailabilityHelper: 'Kaydetmeden önce bir küçük görsel üretir ve ücret doğurabilir', }, model: { + poolEditHelp: 'Modelleri çevrimiçi alın veya elle ekleyin. Tüm modeller düzenlenebilir.', + poolUnavailable: + 'Bu sağlayıcı türü ve API çevrimiçi model almayı desteklemiyor. Model kimliklerini elle ekleyin.', + poolEmpty: 'Model yok. Çevrimiçi alın veya elle ekleyin.', + poolOverwrite: + 'Başarılı bir alma işlemi, elle eklenenler ve düzenlenenler dahil tüm listeyi değiştirecek. Devam edilsin mi?', + poolFetchEmpty: 'Model alınamadı. Liste korundu. Yeniden deneyin veya elle ekleyin.', + poolFetchFailed: + 'Alma işlemi başarısız. Liste korundu. URL, API anahtarı ve ağı kontrol edin ya da elle düzenleyin.', + poolSaveHelp: 'Değişiklikler kaydedilince uygulanır. Kullanımdaki modeller kaldırılamaz.', + + accountType: 'Hesap türü', + accountTypes: { + default: 'Varsayılan', + payAsYouGo: 'Kullandıkça öde', + chinaApi: 'Çin API', + globalApi: 'Küresel API', + chinaCodingPlan: 'Çin Coding Plan', + globalCodingPlan: 'Küresel Coding Plan', + chinaTokenPlan: 'Çin Token Plan', + globalTokenPlan: 'Küresel Token Plan', + speech: 'Konuşma hizmetleri', + codingPlan: 'Coding Plan', + tokenPlan: 'Token Plan', + agentPlan: 'Agent Plan', + go: 'Go', + zen: 'Zen', + }, externalInspect: 'Kontrol et ve getir', externalHealthPassed: 'Sağlık kontrolü başarılı', externalHealthFailed: 'Sağlık kontrolü başarısız', diff --git a/frontend/src/lang/modules/zh-Hant.ts b/frontend/src/lang/modules/zh-Hant.ts index 72187dd77..ef464e613 100644 --- a/frontend/src/lang/modules/zh-Hant.ts +++ b/frontend/src/lang/modules/zh-Hant.ts @@ -1048,6 +1048,31 @@ const message = { validateImageAvailabilityHelper: '驗證時會實際產生一張最小圖片,可能產生費用', }, model: { + poolEditHelp: '線上取得或手動新增,所有模型均可直接編輯。', + poolUnavailable: '目前提供商類型和 API 暫不支援線上取得,請手動新增模型 ID。', + poolEmpty: '清單為空,可線上取得模型或手動新增。', + poolOverwrite: '取得成功後將取代整份清單,手動新增和修改的內容也會被覆蓋。是否繼續?', + poolFetchEmpty: '未取得模型,已保留目前清單。可重試或手動新增。', + poolFetchFailed: '取得失敗,已保留目前清單。請檢查網址、金鑰和網路後重試,或手動維護。', + poolSaveHelp: '儲存後生效。使用中的模型不能從清單移除。', + + accountType: '帳號類型', + accountTypes: { + default: '預設', + payAsYouGo: '按量付費', + chinaApi: '國內 API', + globalApi: '國際 API', + chinaCodingPlan: '國內 Coding Plan', + globalCodingPlan: '國際 Coding Plan', + chinaTokenPlan: '國內 Token Plan', + globalTokenPlan: '國際 Token Plan', + speech: '語音服務', + codingPlan: 'Coding Plan', + tokenPlan: 'Token Plan', + agentPlan: 'Agent Plan', + go: 'Go', + zen: 'Zen', + }, externalInspect: '檢查並取得', externalHealthPassed: '健康檢查通過', externalHealthFailed: '健康檢查失敗', diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts index 2a151881f..8144a3b7e 100644 --- a/frontend/src/lang/modules/zh.ts +++ b/frontend/src/lang/modules/zh.ts @@ -1061,6 +1061,31 @@ const message = { validateImageAvailabilityHelper: '验证时会真实生成一张最小图片,可能产生费用', }, model: { + poolEditHelp: '在线获取或手动添加,所有模型均可直接编辑。', + poolUnavailable: '当前提供商类型和 API 暂不支持在线获取,请手动添加模型 ID。', + poolEmpty: '列表为空,可在线获取模型或手动添加。', + poolOverwrite: '获取成功后将替换整份列表,手动新增和修改的内容也会被覆盖。是否继续?', + poolFetchEmpty: '未获取到模型,已保留当前列表。可重试或手动添加。', + poolFetchFailed: '获取失败,已保留当前列表。请检查地址、密钥和网络后重试,或手动维护。', + poolSaveHelp: '点击保存后生效。正在被使用的模型不能从列表中移除。', + + accountType: '账号类型', + accountTypes: { + default: '默认', + payAsYouGo: '按量付费', + chinaApi: '国内 API', + globalApi: '国际 API', + chinaCodingPlan: '国内 Coding Plan', + globalCodingPlan: '国际 Coding Plan', + chinaTokenPlan: '国内 Token Plan', + globalTokenPlan: '国际 Token Plan', + speech: '语音服务', + codingPlan: 'Coding Plan', + tokenPlan: 'Token Plan', + agentPlan: 'Agent Plan', + go: 'Go', + zen: 'Zen', + }, externalInspect: '检查并获取', externalHealthPassed: '健康检查通过', externalHealthFailed: '健康检查失败', diff --git a/frontend/src/utils/agent-provider-logo.ts b/frontend/src/utils/agent-provider-logo.ts index 0851ed0a6..779273ac4 100644 --- a/frontend/src/utils/agent-provider-logo.ts +++ b/frontend/src/utils/agent-provider-logo.ts @@ -61,17 +61,49 @@ const providerLogos: Record = { color: '#005eeb', }, deepseek: { - src: asset('deepseek.png'), + src: asset('deepseek.svg'), mark: 'DS', background: '#ffffff', color: '#4d6bfe', borderColor: '#dcdfe6', - source: 'https://cdn.deepseek.com/logo.png', + source: 'https://github.com/1Panel-dev/AI-Gateway/blob/main/frontend/src/assets/providers/deepseek.svg', }, bailian: aliyunLogo, 'bailian-coding-plan': aliyunLogo, ark: volcengineLogo, 'ark-coding-plan': volcengineLogo, + tokenhub: { + src: asset('tencentcloud.svg'), + mark: 'TH', + background: '#ffffff', + color: '#111827', + borderColor: '#dcdfe6', + source: 'https://github.com/1Panel-dev/AI-Gateway/blob/main/frontend/src/assets/providers/tencentcloud.svg', + }, + qianfan: { + src: asset('qianfan.svg'), + mark: 'QF', + background: '#ffffff', + color: '#111827', + borderColor: '#dcdfe6', + source: 'https://github.com/1Panel-dev/AI-Gateway/blob/main/frontend/src/assets/providers/qianfan.svg', + }, + siliconflow: { + src: asset('siliconflow.svg'), + mark: 'SF', + background: '#ffffff', + color: '#111827', + borderColor: '#dcdfe6', + source: 'https://github.com/1Panel-dev/AI-Gateway/blob/main/frontend/src/assets/providers/siliconflow.svg', + }, + opencode: { + src: asset('opencode.svg'), + mark: 'OC', + background: '#ffffff', + color: '#111827', + borderColor: '#dcdfe6', + source: 'https://github.com/1Panel-dev/AI-Gateway/blob/main/frontend/src/assets/providers/opencode.svg', + }, zai: { src: asset('zai.webp'), mark: 'Z', @@ -97,7 +129,7 @@ const providerLogos: Record = { source: 'https://www.mi.com/favicon.ico', }, kimi: { - src: asset('kimi.svg'), + src: asset('kimi.png'), mark: 'KM', background: '#ffffff', color: '#111827', @@ -105,7 +137,7 @@ const providerLogos: Record = { source: 'https://moonshotai.github.io/Branding-Guide/', }, 'kimi-coding': { - src: asset('kimi.svg'), + src: asset('kimi.png'), mark: 'KC', background: '#ffffff', color: '#111827', @@ -145,7 +177,7 @@ const providerLogos: Record = { source: 'https://gemini.google.com/', }, moonshot: { - src: asset('kimi.svg'), + src: asset('kimi.png'), mark: 'MS', background: '#ffffff', color: '#111827', diff --git a/frontend/src/views/ai/agents/agent/add/index.vue b/frontend/src/views/ai/agents/agent/add/index.vue index e9cbc35a7..e80ebf502 100644 --- a/frontend/src/views/ai/agents/agent/add/index.vue +++ b/frontend/src/views/ai/agents/agent/add/index.vue @@ -175,6 +175,7 @@ const systemIP = ref(''); const lastAutoAllowedOrigins = ref(''); const allowedOriginsAutoFilled = ref(true); const { isIntl } = useGlobalStore(); +const excludeCodingPlanProviders = computed(() => (isIntl.value ? ['bailian', 'ark'] : [])); const form = reactive({ name: '', @@ -430,7 +431,10 @@ const loadProviderAccountCounts = async (providers: string[]) => { if (providerList.length === 0) { return; } - const res = await countAgentAccountsByProvider({ providers: providerList }); + const res = await countAgentAccountsByProvider({ + providers: providerList, + excludeCodingPlanProviders: excludeCodingPlanProviders.value, + }); const counts = res.data || {}; providerList.forEach((provider) => { providerAccountCount.value[provider] = counts[provider] || 0; @@ -451,11 +455,12 @@ const loadAccounts = async () => { pageSize: 200, provider: form.provider, textOnly: true, + excludeCodingPlanProviders: excludeCodingPlanProviders.value, name: '', }; const res = await pageAgentAccounts(req); accountOptions.value = res.data.items || []; - providerAccountCount.value[form.provider] = res.data.total || accountOptions.value.length; + providerAccountCount.value[form.provider] = res.data.total ?? accountOptions.value.length; if (accountOptions.value.length > 0) { form.accountId = accountOptions.value[0].id; handleAccountChange(); diff --git a/frontend/src/views/ai/agents/agent/config/tabs/agents/create/index.vue b/frontend/src/views/ai/agents/agent/config/tabs/agents/create/index.vue index 6ce5eaf3e..6594d8cca 100644 --- a/frontend/src/views/ai/agents/agent/config/tabs/agents/create/index.vue +++ b/frontend/src/views/ai/agents/agent/config/tabs/agents/create/index.vue @@ -172,7 +172,13 @@ const loadAccounts = async () => { name: '', }); const items = res.data.items || []; - const accountOptions = isIntl.value ? items.filter((item) => !blockedProviders.has(item.provider)) : items; + const accountOptions = isIntl.value + ? items.filter( + (item) => + !blockedProviders.has(item.provider) && + !(['bailian', 'ark'].includes(item.provider) && item.accountType === 'codingPlan'), + ) + : items; const selected = accountOptions.find((item) => item.id === accountId.value); modelOptions.value = (selected?.models || []).map((item) => ({ label: item.name, diff --git a/frontend/src/views/ai/agents/agent/config/tabs/model.vue b/frontend/src/views/ai/agents/agent/config/tabs/model.vue index 45c0b39fe..64685a379 100644 --- a/frontend/src/views/ai/agents/agent/config/tabs/model.vue +++ b/frontend/src/views/ai/agents/agent/config/tabs/model.vue @@ -257,7 +257,13 @@ const load = async (params: AgentModelLoadParams) => { getAgentModelConfig({ agentId: params.agentId }), ]); const items = accountsRes.data.items || []; - accountOptions.value = isIntl.value ? items.filter((item) => !blockedProviders.has(item.provider)) : items; + accountOptions.value = isIntl.value + ? items.filter( + (item) => + !blockedProviders.has(item.provider) && + !(['bailian', 'ark'].includes(item.provider) && item.accountType === 'codingPlan'), + ) + : items; if (accountOptions.value.length === 0) { form.accountId = undefined as unknown as number; form.model = ''; diff --git a/frontend/src/views/ai/model/account-form/index.vue b/frontend/src/views/ai/model/account-form/index.vue index ccba505ac..2b25f52c9 100644 --- a/frontend/src/views/ai/model/account-form/index.vue +++ b/frontend/src/views/ai/model/account-form/index.vue @@ -24,6 +24,20 @@ + + + + + {{ $t('ssh.input') }} @@ -127,163 +141,20 @@ }} - + {{ $t('commons.button.cancel') }} - + {{ $t('commons.button.confirm') }} @@ -320,18 +191,13 @@ + + diff --git a/frontend/src/views/ai/model/model-pool/index.vue b/frontend/src/views/ai/model/model-pool/index.vue index fd8f6a485..1bca438ce 100644 --- a/frontend/src/views/ai/model/model-pool/index.vue +++ b/frontend/src/views/ai/model/model-pool/index.vue @@ -1,77 +1,89 @@ - - - - - - {{ $t('aiTools.agents.ollamaRegisterOnly') }} - - - - - - - - @@ -84,40 +96,42 @@