From 59c657e403177cd98e15a9816e52523fa8558c76 Mon Sep 17 00:00:00 2001 From: CityFun <31820853+zhengkunwang223@users.noreply.github.com> Date: Fri, 20 Mar 2026 15:27:55 +0800 Subject: [PATCH] feat: agent model account support xiaomi (#12242) https://github.com/1Panel-dev/1Panel/issues/12220 --- agent/app/provider/catalog.go | 13 ++++ agent/app/provider/openclaw.go | 18 +++++ agent/app/provider/verify.go | 21 ++++++ agent/app/service/agents_utils.go | 4 +- frontend/src/lang/modules/en.ts | 2 - frontend/src/lang/modules/es-es.ts | 2 - frontend/src/lang/modules/ja.ts | 2 - frontend/src/lang/modules/ko.ts | 2 - frontend/src/lang/modules/ms.ts | 2 - frontend/src/lang/modules/pt-br.ts | 2 - frontend/src/lang/modules/ru.ts | 2 - frontend/src/lang/modules/tr.ts | 2 - frontend/src/lang/modules/zh-Hant.ts | 1 - frontend/src/lang/modules/zh.ts | 1 - .../src/views/ai/agents/model/add/index.vue | 4 +- .../src/views/ai/agents/model/pool/index.vue | 68 +------------------ 16 files changed, 58 insertions(+), 88 deletions(-) diff --git a/agent/app/provider/catalog.go b/agent/app/provider/catalog.go index c591a8385..7f13f19c5 100644 --- a/agent/app/provider/catalog.go +++ b/agent/app/provider/catalog.go @@ -114,6 +114,19 @@ var catalog = map[string]Meta{ {ID: "minimax/MiniMax-M2.5-highspeed", Name: "MiniMax M2.5 highspeed"}, }, }, + "xiaomi": { + Key: "xiaomi", + DisplayName: "Xiaomi", + Sort: 46, + DefaultBaseURL: "https://api.xiaomimimo.com/anthropic", + EnvKey: "XIAOMI_API_KEY", + Models: []Model{ + {ID: "xiaomi/mimo-v2-pro", Name: "Xiaomi MiMo V2 Pro", ContextWindow: 262144, MaxTokens: 8192, Reasoning: false, Input: []string{"text"}}, + {ID: "xiaomi/mimo-v2-omni", Name: "Xiaomi MiMo V2 Omni", ContextWindow: 262144, MaxTokens: 8192, Reasoning: false, Input: []string{"text"}}, + {ID: "xiaomi/mimo-v2-tts", Name: "Xiaomi MiMo V2 TTS", ContextWindow: 262144, MaxTokens: 8192, Reasoning: false, Input: []string{"text"}}, + {ID: "xiaomi/mimo-v2-flash", Name: "Xiaomi MiMo V2 Flash", ContextWindow: 262144, MaxTokens: 8192, Reasoning: false, Input: []string{"text"}}, + }, + }, "kimi": { Key: "kimi", DisplayName: "Kimi (CN)", diff --git a/agent/app/provider/openclaw.go b/agent/app/provider/openclaw.go index 78c494516..3e1242361 100644 --- a/agent/app/provider/openclaw.go +++ b/agent/app/provider/openclaw.go @@ -34,6 +34,8 @@ func BuildOpenClawPatch(provider, modelName, apiType string, maxTokens, contextW return buildArkPatch(modelID, maxTokens, contextWindow, baseURL, apiKey), nil case "minimax": return buildMiniMaxPatch(modelID, baseURL, apiKey), nil + case "xiaomi": + return buildXiaomiPatch(modelID, baseURL, apiKey), nil case "custom", "vllm": return buildCustomPatch(provider, modelName, apiType, maxTokens, contextWindow, baseURL, apiKey), nil case "ollama": @@ -142,6 +144,22 @@ func buildMiniMaxPatch(modelID, baseURL, apiKey string) *OpenClawPatch { } } +func buildXiaomiPatch(modelID, baseURL, apiKey string) *OpenClawPatch { + normalizedID := strings.TrimSpace(modelID) + return &OpenClawPatch{ + PrimaryModel: "xiaomi/" + normalizedID, + Models: providerModels("xiaomi", strings.TrimSpace(apiKey), firstNonEmpty(strings.TrimSpace(baseURL), "https://api.xiaomimimo.com/anthropic"), "anthropic-messages", map[string]interface{}{ + "id": normalizedID, + "name": normalizedID, + "reasoning": false, + "input": []string{"text"}, + "contextWindow": 262144, + "maxTokens": 8192, + "cost": map[string]interface{}{}, + }), + } +} + func buildCustomPatch(provider, modelName, apiType string, maxTokens, contextWindow int, baseURL, apiKey string) *OpenClawPatch { customModelID := normalizeCustomModel(modelName) return &OpenClawPatch{ diff --git a/agent/app/provider/verify.go b/agent/app/provider/verify.go index 02c264721..bb70e540e 100644 --- a/agent/app/provider/verify.go +++ b/agent/app/provider/verify.go @@ -142,6 +142,27 @@ func BuildVerifyRequest(provider, baseURL, apiKey string) VerifyRequest { }}, }}, }) + case "xiaomi": + request.Method = http.MethodPost + headers["x-api-key"] = apiKey + headers["anthropic-version"] = "2023-06-01" + headers["Content-Type"] = "application/json" + if strings.Contains(base, "/v1") { + request.URL = base + "/messages" + } else { + request.URL = base + "/v1/messages" + } + request.Body = mustJSON(map[string]interface{}{ + "model": "mimo-v2-flash", + "max_tokens": 1, + "messages": []map[string]interface{}{{ + "role": "user", + "content": []map[string]string{{ + "type": "text", + "text": "test", + }}, + }}, + }) default: headers["Authorization"] = fmt.Sprintf("Bearer %s", apiKey) if strings.Contains(base, "/v1") { diff --git a/agent/app/service/agents_utils.go b/agent/app/service/agents_utils.go index cda3806c8..f85edc9a5 100644 --- a/agent/app/service/agents_utils.go +++ b/agent/app/service/agents_utils.go @@ -81,7 +81,7 @@ func verifyResolvedAgentAccount(input resolvedAgentAccountVerification) error { } func resolveAgentAccountAPIType(provider, apiType, fallbackAPIType string) (string, error) { - if provider == "minimax" { + if provider == "minimax" || provider == "xiaomi" { return "anthropic-messages", nil } resolvedAPIType := normalizeAPIType(apiType) @@ -1919,6 +1919,8 @@ func fixedProviderBaseURL(provider string) (string, bool) { return providerDefaultBaseURL(provider) case "minimax": return providerDefaultBaseURL(provider) + case "xiaomi": + return providerDefaultBaseURL(provider) default: return "", false } diff --git a/frontend/src/lang/modules/en.ts b/frontend/src/lang/modules/en.ts index 4e3110302..1a6a2e523 100644 --- a/frontend/src/lang/modules/en.ts +++ b/frontend/src/lang/modules/en.ts @@ -694,8 +694,6 @@ const message = { accountModelsRequired: 'Configure at least one model', accountModelsDuplicate: 'Duplicate models exist in the catalog', modelPool: 'Model Pool', - modelPoolHelper: - 'Manage the models exposed by this account here. Agent creation and OpenClaw model switching both use this pool.', modelInputTypes: 'Input Types', reasoning: 'Reasoning Model', token: 'Token', diff --git a/frontend/src/lang/modules/es-es.ts b/frontend/src/lang/modules/es-es.ts index eb543a626..0364eb4da 100644 --- a/frontend/src/lang/modules/es-es.ts +++ b/frontend/src/lang/modules/es-es.ts @@ -702,8 +702,6 @@ const message = { accountModelsRequired: 'Configure at least one model', accountModelsDuplicate: 'Duplicate models exist in the catalog', modelPool: 'Model Pool', - modelPoolHelper: - 'Manage the models exposed by this account here. Agent creation and OpenClaw model switching both use this pool.', modelInputTypes: 'Input Types', reasoning: 'Reasoning Model', token: 'Token', diff --git a/frontend/src/lang/modules/ja.ts b/frontend/src/lang/modules/ja.ts index 708fa64a3..4a7805af5 100644 --- a/frontend/src/lang/modules/ja.ts +++ b/frontend/src/lang/modules/ja.ts @@ -695,8 +695,6 @@ const message = { accountModelsRequired: 'Configure at least one model', accountModelsDuplicate: 'Duplicate models exist in the catalog', modelPool: 'Model Pool', - modelPoolHelper: - 'Manage the models exposed by this account here. Agent creation and OpenClaw model switching both use this pool.', modelInputTypes: 'Input Types', reasoning: 'Reasoning Model', token: 'トークン', diff --git a/frontend/src/lang/modules/ko.ts b/frontend/src/lang/modules/ko.ts index 9d05f6531..7f134bc18 100644 --- a/frontend/src/lang/modules/ko.ts +++ b/frontend/src/lang/modules/ko.ts @@ -687,8 +687,6 @@ const message = { accountModelsRequired: 'Configure at least one model', accountModelsDuplicate: 'Duplicate models exist in the catalog', modelPool: 'Model Pool', - modelPoolHelper: - 'Manage the models exposed by this account here. Agent creation and OpenClaw model switching both use this pool.', modelInputTypes: 'Input Types', reasoning: 'Reasoning Model', token: '토큰', diff --git a/frontend/src/lang/modules/ms.ts b/frontend/src/lang/modules/ms.ts index 58576ca00..b372613fa 100644 --- a/frontend/src/lang/modules/ms.ts +++ b/frontend/src/lang/modules/ms.ts @@ -702,8 +702,6 @@ const message = { accountModelsRequired: 'Configure at least one model', accountModelsDuplicate: 'Duplicate models exist in the catalog', modelPool: 'Model Pool', - modelPoolHelper: - 'Manage the models exposed by this account here. Agent creation and OpenClaw model switching both use this pool.', modelInputTypes: 'Input Types', reasoning: 'Reasoning Model', token: 'Token', diff --git a/frontend/src/lang/modules/pt-br.ts b/frontend/src/lang/modules/pt-br.ts index 33947a7f9..8df225142 100644 --- a/frontend/src/lang/modules/pt-br.ts +++ b/frontend/src/lang/modules/pt-br.ts @@ -697,8 +697,6 @@ const message = { accountModelsRequired: 'Configure at least one model', accountModelsDuplicate: 'Duplicate models exist in the catalog', modelPool: 'Model Pool', - modelPoolHelper: - 'Manage the models exposed by this account here. Agent creation and OpenClaw model switching both use this pool.', modelInputTypes: 'Input Types', reasoning: 'Reasoning Model', token: 'Token', diff --git a/frontend/src/lang/modules/ru.ts b/frontend/src/lang/modules/ru.ts index 6f5828335..342f016ad 100644 --- a/frontend/src/lang/modules/ru.ts +++ b/frontend/src/lang/modules/ru.ts @@ -694,8 +694,6 @@ const message = { accountModelsRequired: 'Configure at least one model', accountModelsDuplicate: 'Duplicate models exist in the catalog', modelPool: 'Model Pool', - modelPoolHelper: - 'Manage the models exposed by this account here. Agent creation and OpenClaw model switching both use this pool.', modelInputTypes: 'Input Types', reasoning: 'Reasoning Model', token: 'Токен', diff --git a/frontend/src/lang/modules/tr.ts b/frontend/src/lang/modules/tr.ts index 271093fa9..fd965c3e7 100644 --- a/frontend/src/lang/modules/tr.ts +++ b/frontend/src/lang/modules/tr.ts @@ -698,8 +698,6 @@ const message = { accountModelsRequired: 'Configure at least one model', accountModelsDuplicate: 'Duplicate models exist in the catalog', modelPool: 'Model Pool', - modelPoolHelper: - 'Manage the models exposed by this account here. Agent creation and OpenClaw model switching both use this pool.', modelInputTypes: 'Input Types', reasoning: 'Reasoning Model', token: 'Token', diff --git a/frontend/src/lang/modules/zh-Hant.ts b/frontend/src/lang/modules/zh-Hant.ts index 1ade8e2b4..40d8cad63 100644 --- a/frontend/src/lang/modules/zh-Hant.ts +++ b/frontend/src/lang/modules/zh-Hant.ts @@ -662,7 +662,6 @@ const message = { accountModelsRequired: '請至少配置一個模型', accountModelsDuplicate: '模型池中存在重複模型,請檢查後重試', modelPool: '模型池', - modelPoolHelper: '在此維護該模型帳號的模型池,建立智能體與 OpenClaw 模型切換都會使用這些模型', modelInputTypes: '輸入類型', reasoning: '推理模型', token: 'Token', diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts index d77d58f7b..a9918e5c8 100644 --- a/frontend/src/lang/modules/zh.ts +++ b/frontend/src/lang/modules/zh.ts @@ -661,7 +661,6 @@ const message = { accountModelsRequired: '请至少配置一个模型', accountModelsDuplicate: '模型池中存在重复模型,请检查后重试', modelPool: '模型池', - modelPoolHelper: '在这里维护该模型账号的模型池,智能体创建和 OpenClaw 模型切换都会使用这些模型', modelInputTypes: '输入类型', reasoning: '推理模型', token: 'Token', diff --git a/frontend/src/views/ai/agents/model/add/index.vue b/frontend/src/views/ai/agents/model/add/index.vue index 4a11bd75e..3af46bfea 100644 --- a/frontend/src/views/ai/agents/model/add/index.vue +++ b/frontend/src/views/ai/agents/model/add/index.vue @@ -115,7 +115,7 @@ const headerTitle = computed(() => const showInitialModel = computed(() => !form.id && initialModelProviders.includes(form.provider)); const apiTypeOptions = computed(() => { - if (form.provider === 'minimax') { + if (form.provider === 'minimax' || form.provider === 'xiaomi') { return ['anthropic-messages']; } if (form.provider === 'custom' || form.provider === 'vllm') { @@ -176,7 +176,7 @@ const resetInitialModel = () => { }; const normalizeProviderAPIType = (provider: string, apiType?: string) => { - if (provider === 'minimax') { + if (provider === 'minimax' || provider === 'xiaomi') { return 'anthropic-messages'; } if (provider === 'ollama') { diff --git a/frontend/src/views/ai/agents/model/pool/index.vue b/frontend/src/views/ai/agents/model/pool/index.vue index f27a1ce61..0015b75db 100644 --- a/frontend/src/views/ai/agents/model/pool/index.vue +++ b/frontend/src/views/ai/agents/model/pool/index.vue @@ -2,13 +2,6 @@