From 89a2def0427d0d7448856677d2fb4c262b9bb0cf Mon Sep 17 00:00:00 2001 From: HybridTalentComputing <1316645276@qq.com> Date: Tue, 23 Dec 2025 22:04:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BAmodel=20picker=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=B1=89=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/chat/ModelPickerModal.tsx | 43 +++++++++++-------- webview-ui/src/locales/en/common.json | 21 ++++++++- webview-ui/src/locales/zh-CN/common.json | 21 ++++++++- 3 files changed, 66 insertions(+), 19 deletions(-) diff --git a/webview-ui/src/components/chat/ModelPickerModal.tsx b/webview-ui/src/components/chat/ModelPickerModal.tsx index c03e7d52..de5278a6 100644 --- a/webview-ui/src/components/chat/ModelPickerModal.tsx +++ b/webview-ui/src/components/chat/ModelPickerModal.tsx @@ -6,6 +6,7 @@ import { Mode } from "@shared/storage/types" import { ArrowLeftRight, Brain, Check, ChevronDownIcon, Search, Settings } from "lucide-react" import React, { useCallback, useEffect, useMemo, useRef, useState } from "react" import { createPortal } from "react-dom" +import { useTranslation } from "react-i18next" import { useWindowSize } from "react-use" import styled from "styled-components" import { CODE_BLOCK_BG_COLOR } from "@/components/common/CodeBlock" @@ -33,6 +34,7 @@ const getProviderInfo = ( provider: ApiProvider, apiConfiguration: any, effectiveMode: "plan" | "act", + t: (key: string) => string, ): { modelId?: string; baseUrl?: string; helpText: string } => { switch (provider) { case "lmstudio": @@ -40,79 +42,79 @@ const getProviderInfo = ( modelId: effectiveMode === "plan" ? apiConfiguration.planModeLmStudioModelId : apiConfiguration.actModeLmStudioModelId, baseUrl: apiConfiguration.lmStudioBaseUrl, - helpText: "Start LM Studio and load a model to begin", + helpText: t("settings.apiConfig.providerHelpText.lmstudio"), } case "ollama": return { modelId: effectiveMode === "plan" ? apiConfiguration.planModeOllamaModelId : apiConfiguration.actModeOllamaModelId, baseUrl: apiConfiguration.ollamaBaseUrl, - helpText: "Run `ollama serve` and pull a model", + helpText: t("settings.apiConfig.providerHelpText.ollama"), } case "litellm": return { modelId: effectiveMode === "plan" ? apiConfiguration.planModeLiteLlmModelId : apiConfiguration.actModeLiteLlmModelId, baseUrl: apiConfiguration.liteLlmBaseUrl, - helpText: "Add your LiteLLM proxy URL in settings", + helpText: t("settings.apiConfig.providerHelpText.litellm"), } case "openai": return { modelId: effectiveMode === "plan" ? apiConfiguration.planModeOpenAiModelId : apiConfiguration.actModeOpenAiModelId, baseUrl: apiConfiguration.openAiBaseUrl, - helpText: "Add your OpenAI API key and endpoint", + helpText: t("settings.apiConfig.providerHelpText.openai"), } case "vscode-lm": return { modelId: undefined, baseUrl: undefined, - helpText: "Select a VS Code language model from settings", + helpText: t("settings.apiConfig.providerHelpText.vscode-lm"), } case "requesty": return { modelId: effectiveMode === "plan" ? apiConfiguration.planModeRequestyModelId : apiConfiguration.actModeRequestyModelId, baseUrl: apiConfiguration.requestyBaseUrl, - helpText: "Add your Requesty API key in settings", + helpText: t("settings.apiConfig.providerHelpText.requesty"), } case "together": return { modelId: effectiveMode === "plan" ? apiConfiguration.planModeTogetherModelId : apiConfiguration.actModeTogetherModelId, baseUrl: undefined, - helpText: "Add your Together AI API key in settings", + helpText: t("settings.apiConfig.providerHelpText.together"), } case "dify": return { modelId: undefined, baseUrl: apiConfiguration.difyBaseUrl, - helpText: "Configure your Dify workflow URL and API key", + helpText: t("settings.apiConfig.providerHelpText.dify"), } case "hicap": return { modelId: effectiveMode === "plan" ? apiConfiguration.planModeHicapModelId : apiConfiguration.actModeHicapModelId, baseUrl: undefined, - helpText: "Add your HiCap API key in settings", + helpText: t("settings.apiConfig.providerHelpText.hicap"), } case "oca": return { modelId: effectiveMode === "plan" ? apiConfiguration.planModeOcaModelId : apiConfiguration.actModeOcaModelId, baseUrl: apiConfiguration.ocaBaseUrl, - helpText: "Configure your OCA endpoint in settings", + helpText: t("settings.apiConfig.providerHelpText.oca"), } case "aihubmix": return { modelId: effectiveMode === "plan" ? apiConfiguration.planModeAihubmixModelId : apiConfiguration.actModeAihubmixModelId, baseUrl: apiConfiguration.aihubmixBaseUrl, - helpText: "Add your AIHubMix API key in settings", + helpText: t("settings.apiConfig.providerHelpText.aihubmix"), } default: return { modelId: undefined, baseUrl: undefined, - helpText: "Configure this provider in model settings", + helpText: t("settings.apiConfig.providerHelpText.default"), } } } @@ -173,6 +175,7 @@ const StarIcon = ({ isFavorite, onClick }: { isFavorite: boolean; onClick: (e: R } const ModelPickerModal: React.FC = ({ isOpen, onOpenChange, currentMode, children }) => { + const { t } = useTranslation() const { apiConfiguration, openRouterModels, @@ -834,20 +837,24 @@ const ModelPickerModal: React.FC = ({ isOpen, onOpenChang {/* Settings-only providers: show configured model info and help text */} {SETTINGS_ONLY_PROVIDERS.includes(selectedProvider) && (() => { - const providerInfo = getProviderInfo(selectedProvider, apiConfiguration, effectiveMode) + const providerInfo = getProviderInfo(selectedProvider, apiConfiguration, effectiveMode, t) return ( {/* Show configured model if exists */} {providerInfo.modelId && ( - Current model: + + {t("settings.apiConfig.currentModel")} + {providerInfo.modelId} )} {/* Show base URL if configured */} {providerInfo.baseUrl && ( - Endpoint: + + {t("settings.apiConfig.endpoint")} + {providerInfo.baseUrl} )} @@ -857,7 +864,9 @@ const ModelPickerModal: React.FC = ({ isOpen, onOpenChang - {providerInfo.modelId ? "Edit in settings" : "Configure in settings"} + {providerInfo.modelId + ? t("settings.apiConfig.editInSettings") + : t("settings.apiConfig.configureInSettings")} @@ -869,7 +878,7 @@ const ModelPickerModal: React.FC = ({ isOpen, onOpenChang filteredModels.length === 0 && featuredModels.length === 0 && !SETTINGS_ONLY_PROVIDERS.includes(selectedProvider) && ( - No models found + {t("settings.apiConfig.noModelsFound")} )} diff --git a/webview-ui/src/locales/en/common.json b/webview-ui/src/locales/en/common.json index b218855f..f01386a3 100644 --- a/webview-ui/src/locales/en/common.json +++ b/webview-ui/src/locales/en/common.json @@ -249,7 +249,26 @@ "planMode": "Plan Mode", "actMode": "Act Mode", "separateModels": "Use different models for Plan and Act modes", - "separateModelsDescription": "Switching between Plan and Act mode will persist the API and model used in the previous mode. This may be helpful e.g. when using a strong reasoning model to architect a plan for a cheaper coding model to act on." + "separateModelsDescription": "Switching between Plan and Act mode will persist the API and model used in the previous mode. This may be helpful e.g. when using a strong reasoning model to architect a plan for a cheaper coding model to act on.", + "currentModel": "Current model:", + "endpoint": "Endpoint:", + "editInSettings": "Edit in settings", + "configureInSettings": "Configure in settings", + "noModelsFound": "No models found", + "providerHelpText": { + "lmstudio": "Start LM Studio and load a model to begin", + "ollama": "Run `ollama serve` and pull a model", + "litellm": "Add your LiteLLM proxy URL in settings", + "openai": "Add your OpenAI API key and endpoint", + "vscode-lm": "Select a VS Code language model from settings", + "requesty": "Add your Requesty API key in settings", + "together": "Add your Together AI API key in settings", + "dify": "Configure your Dify workflow URL and API key", + "hicap": "Add your HiCap API key in settings", + "oca": "Configure your OCA endpoint in settings", + "aihubmix": "Add your AIHubMix API key in settings", + "default": "Configure this provider in model settings" + } }, "providers": { "model": "Model", diff --git a/webview-ui/src/locales/zh-CN/common.json b/webview-ui/src/locales/zh-CN/common.json index ff1b2825..57faf926 100644 --- a/webview-ui/src/locales/zh-CN/common.json +++ b/webview-ui/src/locales/zh-CN/common.json @@ -249,7 +249,26 @@ "planMode": "计划模式", "actMode": "执行模式", "separateModels": "为计划和执行模式使用不同的模型", - "separateModelsDescription": "在计划和执行模式之间切换时,将保留上一模式中使用的 API 和模型。例如,在使用强大的推理模型构建计划,并由较便宜的编码模型执行时,这会很有帮助。" + "separateModelsDescription": "在计划和执行模式之间切换时,将保留上一模式中使用的 API 和模型。例如,在使用强大的推理模型构建计划,并由较便宜的编码模型执行时,这会很有帮助。", + "currentModel": "当前模型:", + "endpoint": "端点:", + "editInSettings": "在设置中编辑", + "configureInSettings": "在设置中配置", + "noModelsFound": "未找到模型", + "providerHelpText": { + "lmstudio": "启动 LM Studio 并加载模型以开始", + "ollama": "运行 `ollama serve` 并拉取模型", + "litellm": "在设置中添加您的 LiteLLM 代理 URL", + "openai": "在设置中添加您的 OpenAI API 密钥和端点", + "vscode-lm": "在设置中选择 VS Code 语言模型", + "requesty": "在设置中添加您的 Requesty API 密钥", + "together": "在设置中添加您的 Together AI API 密钥", + "dify": "配置您的 Dify 工作流 URL 和 API 密钥", + "hicap": "在设置中添加您的 HiCap API 密钥", + "oca": "在设置中配置您的 OCA 端点", + "aihubmix": "在设置中添加您的 AIHubMix API 密钥", + "default": "在模型设置中配置此提供商" + } }, "providers": { "model": "模型",