🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
🔨 chore: Optimized model owner parse (#9000)
sxjerub0e163cb2bbb
diff --git a/packages/model-runtime/src/utils/modelParse.test.ts b/packages/model-runtime/src/utils/modelParse.test.tsindex 5f9264557b0..76a90359012 100644--- a/packages/model-runtime/src/utils/modelParse.test.ts+++ b/packages/model-runtime/src/utils/modelParse.test.ts@@ -4,7 +4,7 @@ import type { ChatModelCard } from '@/types/llm';import {MODEL_LIST_CONFIGS,- PROVIDER_DETECTION_CONFIG,+ MODEL_OWNER_DETECTION_CONFIG,detectModelProvider,processModelList,processMultiProviderModelList,@@ -754,7 +754,7 @@ describe('modelParse', () => {describe('MODEL_LIST_CONFIGS and PROVIDER_DETECTION_CONFIG', () => {it('should have matching keys in both configuration objects', () => {const modelConfigKeys = Object.keys(MODEL_LIST_CONFIGS);- const providerDetectionKeys = Object.keys(PROVIDER_DETECTION_CONFIG);+ const providerDetectionKeys = Object.keys(MODEL_OWNER_DETECTION_CONFIG);expect(modelConfigKeys.sort()).toEqual(providerDetectionKeys.sort());});});diff --git a/packages/model-runtime/src/utils/modelParse.ts b/packages/model-runtime/src/utils/modelParse.tsindex 1add509faaa..77d6edd1cb6 100644--- a/packages/model-runtime/src/utils/modelParse.ts+++ b/packages/model-runtime/src/utils/modelParse.ts@@ -25,16 +25,16 @@ export const MODEL_LIST_CONFIGS = {reasoningKeywords: ['thinking', '-2.5-'],visionKeywords: ['gemini', 'learnlm'],},+ llama: {+ functionCallKeywords: ['llama-3.2', 'llama-3.3', 'llama-4'],+ reasoningKeywords: [],+ visionKeywords: ['llava'],+ },moonshot: {functionCallKeywords: ['moonshot', 'kimi'],reasoningKeywords: ['thinking'],visionKeywords: ['vision', 'kimi-latest', 'kimi-thinking-preview'],},- ollama: {- functionCallKeywords: ['llama-3.2', 'llama-3.3', 'llama-4'],- reasoningKeywords: [],- visionKeywords: ['llava'],- },openai: {excludeKeywords: ['audio'],functionCallKeywords: ['4o', '4.1', 'o3', 'o4', 'oss'],@@ -81,13 +81,13 @@ export const MODEL_LIST_CONFIGS = {},} as const;-// 模型提供商关键词配置-export const PROVIDER_DETECTION_CONFIG = {+// 模型所有者 (提供商) 关键词配置+export const MODEL_OWNER_DETECTION_CONFIG = {anthropic: ['claude'],deepseek: ['deepseek'],google: ['gemini', 'imagen'],+ llama: ['llama', 'llava'],moonshot: ['moonshot', 'kimi'],- ollama: ['llama', 'llava'],openai: ['o1', 'o3', 'o4', 'gpt-'],qwen: ['qwen', 'qwq', 'qvq'],v0: ['v0'],@@ -175,7 +175,12 @@ const findKnownModelByProvider = async (// 尝试动态导入对应的配置文件const modules = await import('model-bank');- const providerModels = modules[provider];+ // 如果提供商配置文件不存在,跳过+ if (!(provider in modules)) {+ return null;+ }++ const providerModels = modules[provider as keyof typeof modules];// 如果导入成功且有数据,进行查找if (Array.isArray(providerModels)) {@@ -197,7 +202,7 @@ const findKnownModelByProvider = async (export const detectModelProvider = (modelId: string): keyof typeof MODEL_LIST_CONFIGS => {const lowerModelId = modelId.toLowerCase();- for (const [provider, keywords] of Object.entries(PROVIDER_DETECTION_CONFIG)) {+ for (const [provider, keywords] of Object.entries(MODEL_OWNER_DETECTION_CONFIG)) {const hasKeyword = isKeywordListMatch(lowerModelId, keywords);if (hasKeyword && provider in MODEL_LIST_CONFIGS) {