diff --git a/src/app/api/chat/models/[provider]/route.ts b/src/app/api/chat/models/[provider]/route.ts index f1aa07c55fbc..64c5d423f2c1 100644 --- a/src/app/api/chat/models/[provider]/route.ts +++ b/src/app/api/chat/models/[provider]/route.ts @@ -12,15 +12,18 @@ export const runtime = 'edge'; export const preferredRegion = getPreferredRegion(); +const noNeedAPIKey = (provider: string) => + [ModelProvider.OpenRouter, ModelProvider.TogetherAI].includes(provider as any); + export const GET = checkAuth(async (req, { params, jwtPayload }) => { const { provider } = params; try { - const openRouterKey = jwtPayload.apiKey || 'openrouter-dont-need-api-key-for-model-list'; + const hasDefaultApiKey = jwtPayload.apiKey || 'dont-need-api-key-for-model-list'; const agentRuntime = await AgentRuntime.initializeWithUserPayload(provider, { ...jwtPayload, - apiKey: provider === ModelProvider.OpenRouter ? openRouterKey : jwtPayload.apiKey, + apiKey: noNeedAPIKey(provider) ? hasDefaultApiKey : jwtPayload.apiKey, }); const list = await agentRuntime.models(); diff --git a/src/components/ModelIcon/index.tsx b/src/components/ModelIcon/index.tsx index 80c0e4a6edb7..1ef851d88410 100644 --- a/src/components/ModelIcon/index.tsx +++ b/src/components/ModelIcon/index.tsx @@ -3,16 +3,21 @@ import { Baichuan, ChatGLM, Claude, + Cohere, Gemini, Gemma, + Hunyuan, LLaVA, Meta, Minimax, Mistral, Moonshot, OpenAI, + OpenRouter, Perplexity, + Spark, Tongyi, + Wenxin, Yi, } from '@lobehub/icons'; import { memo } from 'react'; @@ -28,9 +33,9 @@ const ModelIcon = memo(({ model: originModel, size = 12 // lower case the origin model so to better match more model id case const model = originModel.toLowerCase(); - if (model.startsWith('gpt-3')) return ; - if (model.startsWith('gpt-4')) return ; - if (model.startsWith('glm')) return ; + if (model.includes('gpt-3')) return ; + if (model.includes('gpt-4')) return ; + if (model.startsWith('glm') || model.includes('chatglm')) return ; if (model.includes('claude')) return ; if (model.includes('titan')) return ; if (model.includes('llama')) return ; @@ -42,9 +47,19 @@ const ModelIcon = memo(({ model: originModel, size = 12 if (model.includes('moonshot')) return ; if (model.includes('baichuan')) return ; + if (model.includes('mistral') || model.includes('mixtral')) return ; - if (model.includes('pplx')) return ; + + if (model.includes('pplx') || model.includes('sonar')) return ; + if (model.includes('yi-')) return ; + if (model.includes('openrouter')) return ; + if (model.includes('command')) return ; + + if (model.includes('ernie')) return ; + if (model.includes('spark')) return ; + if (model.includes('hunyuan')) return ; + if (model.includes('abab')) return ; }); export default ModelIcon;