From 8bcd229849018b8af5c8f450c61a66d4391ea09a Mon Sep 17 00:00:00 2001 From: kangfenmao Date: Thu, 25 Sep 2025 22:11:17 +0800 Subject: [PATCH] feat: enhance model filtering based on supported endpoint types - Updated CodeToolsPage to include checks for supported endpoint types for various CLI tools. - Added 'cherryin' to GEMINI_SUPPORTED_PROVIDERS and updated CLAUDE_SUPPORTED_PROVIDERS to include it. - Improved logic for determining model compatibility with selected CLI tools, enhancing overall functionality. --- src/renderer/src/pages/code/CodeToolsPage.tsx | 27 ++++++++++++++++++- src/renderer/src/pages/code/index.ts | 12 ++++++--- 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/src/renderer/src/pages/code/CodeToolsPage.tsx b/src/renderer/src/pages/code/CodeToolsPage.tsx index 69d9fb728d..b64833f6d6 100644 --- a/src/renderer/src/pages/code/CodeToolsPage.tsx +++ b/src/renderer/src/pages/code/CodeToolsPage.tsx @@ -13,7 +13,7 @@ import { loggerService } from '@renderer/services/LoggerService' import { getModelUniqId } from '@renderer/services/ModelService' import { useAppDispatch, useAppSelector } from '@renderer/store' import { setIsBunInstalled } from '@renderer/store/mcp' -import { Model } from '@renderer/types' +import { EndpointType, Model } from '@renderer/types' import { codeTools, terminalApps, TerminalConfig } from '@shared/config/constant' import { Alert, Avatar, Button, Checkbox, Input, Popover, Select, Space, Tooltip } from 'antd' import { ArrowUpRight, Download, FolderOpen, HelpCircle, Terminal, X } from 'lucide-react' @@ -70,18 +70,43 @@ const CodeToolsPage: FC = () => { if (isEmbeddingModel(m) || isRerankModel(m) || isTextToImageModel(m)) { return false } + if (m.provider === 'cherryai') { return false } + if (selectedCliTool === codeTools.claudeCode) { + if (m.supported_endpoint_types) { + return m.supported_endpoint_types.includes('anthropic') + } return m.id.includes('claude') || CLAUDE_OFFICIAL_SUPPORTED_PROVIDERS.includes(m.provider) } + if (selectedCliTool === codeTools.geminiCli) { + if (m.supported_endpoint_types) { + return m.supported_endpoint_types.includes('gemini') + } return m.id.includes('gemini') } + if (selectedCliTool === codeTools.openaiCodex) { + if (m.supported_endpoint_types) { + return ['openai', 'openai-response'].some((type) => + m.supported_endpoint_types?.includes(type as EndpointType) + ) + } return m.id.includes('openai') || OPENAI_CODEX_SUPPORTED_PROVIDERS.includes(m.provider) } + + if (selectedCliTool === codeTools.qwenCode || selectedCliTool === codeTools.iFlowCli) { + if (m.supported_endpoint_types) { + return ['openai', 'openai-response'].some((type) => + m.supported_endpoint_types?.includes(type as EndpointType) + ) + } + return true + } + return true }, [selectedCliTool] diff --git a/src/renderer/src/pages/code/index.ts b/src/renderer/src/pages/code/index.ts index f286704d39..531a7f5f01 100644 --- a/src/renderer/src/pages/code/index.ts +++ b/src/renderer/src/pages/code/index.ts @@ -23,10 +23,16 @@ export const CLI_TOOLS = [ { value: codeTools.iFlowCli, label: 'iFlow CLI' } ] -export const GEMINI_SUPPORTED_PROVIDERS = ['aihubmix', 'dmxapi', 'new-api'] +export const GEMINI_SUPPORTED_PROVIDERS = ['aihubmix', 'dmxapi', 'new-api', 'cherryin'] export const CLAUDE_OFFICIAL_SUPPORTED_PROVIDERS = ['deepseek', 'moonshot', 'zhipu', 'dashscope', 'modelscope'] -export const CLAUDE_SUPPORTED_PROVIDERS = ['aihubmix', 'dmxapi', 'new-api', ...CLAUDE_OFFICIAL_SUPPORTED_PROVIDERS] -export const OPENAI_CODEX_SUPPORTED_PROVIDERS = ['openai', 'openrouter', 'aihubmix', 'new-api'] +export const CLAUDE_SUPPORTED_PROVIDERS = [ + 'aihubmix', + 'dmxapi', + 'new-api', + 'cherryin', + ...CLAUDE_OFFICIAL_SUPPORTED_PROVIDERS +] +export const OPENAI_CODEX_SUPPORTED_PROVIDERS = ['openai', 'openrouter', 'aihubmix', 'new-api', 'cherryin'] // Provider 过滤映射 export const CLI_TOOL_PROVIDER_MAP: Record Provider[]> = {