为model picker添加汉化

This commit is contained in:
HybridTalentComputing committed 2025-12-23 22:04:40 +08:00
1 parent 835ab199fd
commit 89a2def042
3 files changed
+66 -19

No files matched your search

@@ -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<ModelPickerModalProps> = ({ isOpen, onOpenChange, currentMode, children }) => {
const { t } = useTranslation()
const {
apiConfiguration,
openRouterModels,
@@ -834,20 +837,24 @@ const ModelPickerModal: React.FC<ModelPickerModalProps> = ({ 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 (
<SettingsOnlyContainer>
{/* Show configured model if exists */}
{providerInfo.modelId && (
<ConfiguredModelRow>
<ConfiguredModelLabel>Current model:</ConfiguredModelLabel>
<ConfiguredModelLabel>
{t("settings.apiConfig.currentModel")}
</ConfiguredModelLabel>
<ConfiguredModelName>{providerInfo.modelId}</ConfiguredModelName>
</ConfiguredModelRow>
)}
{/* Show base URL if configured */}
{providerInfo.baseUrl && (
<ConfiguredModelRow>
<ConfiguredModelLabel>Endpoint:</ConfiguredModelLabel>
<ConfiguredModelLabel>
{t("settings.apiConfig.endpoint")}
</ConfiguredModelLabel>
<ConfiguredModelUrl>{providerInfo.baseUrl}</ConfiguredModelUrl>
</ConfiguredModelRow>
)}
@@ -857,7 +864,9 @@ const ModelPickerModal: React.FC<ModelPickerModalProps> = ({ isOpen, onOpenChang
<SettingsOnlyLink onClick={handleConfigureClick}>
<Settings size={12} />
<span>
{providerInfo.modelId ? "Edit in settings" : "Configure in settings"}
{providerInfo.modelId
? t("settings.apiConfig.editInSettings")
: t("settings.apiConfig.configureInSettings")}
</span>
</SettingsOnlyLink>
</SettingsOnlyContainer>
@@ -869,7 +878,7 @@ const ModelPickerModal: React.FC<ModelPickerModalProps> = ({ isOpen, onOpenChang
filteredModels.length === 0 &&
featuredModels.length === 0 &&
!SETTINGS_ONLY_PROVIDERS.includes(selectedProvider) && (
<EmptyState>No models found</EmptyState>
<EmptyState>{t("settings.apiConfig.noModelsFound")}</EmptyState>
)}
</>
</ModelListContainer>
+20 -1
View File
@@ -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",
+20 -1
View File
@@ -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": "模型",