diff --git a/src/config/aiModels/ai360.ts b/src/config/aiModels/ai360.ts index 1a5939b73895..743cde3c0524 100644 --- a/src/config/aiModels/ai360.ts +++ b/src/config/aiModels/ai360.ts @@ -2,16 +2,29 @@ import { AIChatModelCard } from '@/types/aiModel'; const ai360ChatModels: AIChatModelCard[] = [ { - contextWindowTokens: 8192, + contextWindowTokens: 8000, description: - '360GPT2 Pro 是 360 公司推出的高级自然语言处理模型,具备卓越的文本生成和理解能力,尤其在生成与创作领域表现出色,能够处理复杂的语言转换和角色演绎任务。', + '360gpt2-o1 使用树搜索构建思维链,并引入了反思机制,使用强化学习训练,模型具备自我反思与纠错的能力。', + displayName: '360GPT2 o1', + enabled: true, + id: '360gpt2-o1', + pricing: { + currency: 'CNY', + input: 20, + output: 50, + }, + type: 'chat', + }, + { + contextWindowTokens: 8000, + description: + '360智脑系列效果最好的主力千亿级大模型,广泛适用于各领域复杂任务场景。', displayName: '360GPT2 Pro', enabled: true, id: '360gpt2-pro', - maxOutput: 7000, pricing: { currency: 'CNY', - input: 5, + input: 2, output: 5, }, type: 'chat', @@ -20,46 +33,29 @@ const ai360ChatModels: AIChatModelCard[] = [ abilities: { functionCall: true, }, - contextWindowTokens: 8192, + contextWindowTokens: 8000, description: - '360GPT Pro 作为 360 AI 模型系列的重要成员,以高效的文本处理能力满足多样化的自然语言应用场景,支持长文本理解和多轮对话等功能。', + '360智脑系列效果最好的主力千亿级大模型,广泛适用于各领域复杂任务场景。', displayName: '360GPT Pro', enabled: true, id: '360gpt-pro', - maxOutput: 7000, pricing: { currency: 'CNY', - input: 5, + input: 2, output: 5, }, type: 'chat', }, { - contextWindowTokens: 8192, + contextWindowTokens: 7000, description: - '360GPT Turbo 提供强大的计算和对话能力,具备出色的语义理解和生成效率,是企业和开发者理想的智能助理解决方案。', + '兼顾性能和效果的百亿级大模型,适合对性能/成本要求较高 的场景。', displayName: '360GPT Turbo', enabled: true, id: '360gpt-turbo', - maxOutput: 7000, pricing: { currency: 'CNY', - input: 2, - output: 2, - }, - type: 'chat', - }, - { - contextWindowTokens: 8192, - description: - '360GPT Turbo Responsibility 8K 强调语义安全和责任导向,专为对内容安全有高度要求的应用场景设计,确保用户体验的准确性与稳健性。', - displayName: '360GPT Turbo Responsibility 8K', - enabled: true, - id: '360gpt-turbo-responsibility-8k', - maxOutput: 2048, - pricing: { - currency: 'CNY', - input: 2, + input: 1, output: 2, }, type: 'chat', diff --git a/src/config/aiModels/giteeai.ts b/src/config/aiModels/giteeai.ts index afc3e67bbc1d..badd9eb41312 100644 --- a/src/config/aiModels/giteeai.ts +++ b/src/config/aiModels/giteeai.ts @@ -7,24 +7,35 @@ const giteeaiChatModels: AIChatModelCard[] = [ }, contextWindowTokens: 16_000, description: - 'Qwen2.5-72B-Instruct 支持 16k 上下文, 生成长文本超过 8K 。支持 function call 与外部系统无缝交互,极大提升了灵活性和扩展性。模型知识明显增加,并且大大提高了编码和数学能力, 多语言支持超过 29 种', + 'Qwen2.5-72B-Instruct 支持 16k 上下文, 生成长文本超过 8K 。支持 function call 与外部系统无缝交互,极大提升了灵活性和扩展性。模型知识明显增加,并且大大提高了编码和数学能力, 多语言支持超过 29 种', displayName: 'Qwen2.5 72B Instruct', enabled: true, id: 'Qwen2.5-72B-Instruct', type: 'chat', }, { + contextWindowTokens: 32_000, description: - 'Qwen2.5-Coder-32B-Instruct 是一款专为代码生成、代码理解和高效开发场景设计的大型语言模型,采用了业界领先的32B参数规模,能够满足多样化的编程需求。', - displayName: 'Qwen2.5 Coder 32B Instruct', + 'Qwen2.5-32B-Instruct 是一款 320 亿参数的大语言模型,性能表现均衡,优化中文和多语言场景,支持智能问答、内容生成等应用。', + displayName: 'Qwen2.5 32B Instruct', enabled: true, - id: 'Qwen2.5-Coder-32B-Instruct', + id: 'Qwen2.5-32B-Instruct', + type: 'chat', + }, + { + contextWindowTokens: 24_000, + description: + 'Qwen2.5-14B-Instruct 是一款 140 亿参数的大语言模型,性能表现优秀,优化中文和多语言场景,支持智能问答、内容生成等应用。', + displayName: 'Qwen2.5 14B Instruct', + enabled: true, + id: 'Qwen2.5-14B-Instruct', type: 'chat', }, { abilities: { functionCall: true, }, + contextWindowTokens: 32_000, description: 'Qwen2.5-7B-Instruct 是一款 70 亿参数的大语言模型,支持 function call 与外部系统无缝交互,极大提升了灵活性和扩展性。优化中文和多语言场景,支持智能问答、内容生成等应用。', displayName: 'Qwen2.5 7B Instruct', @@ -33,52 +44,56 @@ const giteeaiChatModels: AIChatModelCard[] = [ type: 'chat', }, { + contextWindowTokens: 32_000, description: - 'Qwen2.5-32B-Instruct 是一款 320 亿参数的大语言模型,性能表现均衡,优化中文和多语言场景,支持智能问答、内容生成等应用。', - displayName: 'Qwen2.5 32B Instruct', - enabled: true, - id: 'Qwen2.5-32B-Instruct', + 'Qwen2 是 Qwen 模型的最新系列,支持 128k 上下文,对比当前最优的开源模型,Qwen2-72B 在自然语言理解、知识、代码、数学及多语言等多项能力上均显著超越当前领先的模型。', + displayName: 'Qwen2 72B Instruct', + id: 'Qwen2-72B-Instruct', type: 'chat', }, { + contextWindowTokens: 24_000, description: - 'Qwen2.5-14B-Instruct 是一款 140 亿参数的大语言模型,性能表现优秀,优化中文和多语言场景,支持智能问答、内容生成等应用。', - displayName: 'Qwen2.5 14B Instruct', - enabled: true, - id: 'Qwen2.5-14B-Instruct', + 'Qwen2 是 Qwen 模型的最新系列,能够超越同等规模的最优开源模型甚至更大规模的模型,Qwen2 7B 在多个评测上取得显著的优势,尤其是代码及中文理解上。', + displayName: 'Qwen2 7B Instruct', + id: 'Qwen2-7B-Instruct', type: 'chat', }, { - contextWindowTokens: 6000, + contextWindowTokens: 32_000, description: - 'Qwen2 是 Qwen 模型的最新系列,支持 128k 上下文,对比当前最优的开源模型,Qwen2-72B 在自然语言理解、知识、代码、数学及多语言等多项能力上均显著超越当前领先的模型。', - displayName: 'Qwen2 72B Instruct', - id: 'Qwen2-72B-Instruct', + 'Qwen2.5-Coder-32B-Instruct 是一款专为代码生成、代码理解和高效开发场景设计的大型语言模型,采用了业界领先的32B参数规模,能够满足多样化的编程需求。', + displayName: 'Qwen2.5 Coder 32B Instruct', + enabled: true, + id: 'Qwen2.5-Coder-32B-Instruct', type: 'chat', }, { - contextWindowTokens: 32_000, + contextWindowTokens: 24_000, description: - 'Qwen2 是 Qwen 模型的最新系列,能够超越同等规模的最优开源模型甚至更大规模的模型,Qwen2 7B 在多个评测上取得显著的优势,尤其是代码及中文理解上。', - displayName: 'Qwen2 7B Instruct', - id: 'Qwen2-7B-Instruct', + 'Qwen2.5-Coder-14B-Instruct 是一款基于大规模预训练的编程指令模型,具备强大的代码理解和生成能力,能够高效地处理各种编程任务,特别适合智能代码编写、自动化脚本生成和编程问题解答。', + displayName: 'Qwen2.5 Coder 14B Instruct', + enabled: true, + id: 'Qwen2.5-Coder-14B-Instruct', type: 'chat', }, { abilities: { vision: true, }, + contextWindowTokens: 32_000, description: - 'InternVL2-8B 是一款强大的视觉语言模型,支持图像与文本的多模态处理,能够精确识别图像内容并生成相关描述或回答。', - displayName: 'InternVL2 8B', + 'Qwen2-VL-72B是一款强大的视觉语言模型,支持图像与文本的多模态处理,能够精确识别图像内容并生成相关描述或回答。', + displayName: 'Qwen2 VL 72B', enabled: true, - id: 'InternVL2-8B', + id: 'Qwen2-VL-72B', type: 'chat', }, { abilities: { vision: true, }, + contextWindowTokens: 32_000, description: 'InternVL2.5-26B 是一款强大的视觉语言模型,支持图像与文本的多模态处理,能够精确识别图像内容并生成相关描述或回答。', displayName: 'InternVL2.5 26B', @@ -86,6 +101,18 @@ const giteeaiChatModels: AIChatModelCard[] = [ id: 'InternVL2.5-26B', type: 'chat', }, + { + abilities: { + vision: true, + }, + contextWindowTokens: 32_000, + description: + 'InternVL2-8B 是一款强大的视觉语言模型,支持图像与文本的多模态处理,能够精确识别图像内容并生成相关描述或回答。', + displayName: 'InternVL2 8B', + enabled: true, + id: 'InternVL2-8B', + type: 'chat', + }, { contextWindowTokens: 32_000, description: @@ -104,25 +131,28 @@ const giteeaiChatModels: AIChatModelCard[] = [ id: 'Yi-34B-Chat', type: 'chat', }, +/* + // not compatible with OpenAI SDK { - contextWindowTokens: 8000, description: - 'DeepSeek Coder 33B 是一个代码语言模型, 基于 2 万亿数据训练而成,其中 87% 为代码, 13% 为中英文语言。模型引入 16K 窗口大小和填空任务,提供项目级别的代码补全和片段填充功能。', - displayName: 'DeepSeek Coder 33B Instruct', + '代码小浣熊是基于商汤大语言模型的软件智能研发助手,覆盖软件需求分析、架构设计、代码编写、软件测试等环节,满足用户代码编写、编程学习等各类需求。代码小浣熊支持 Python、Java、JavaScript、C++、Go、SQL 等 90+主流编程语言和 VS Code、IntelliJ IDEA 等主流 IDE。在实际应用中,代码小浣熊可帮助开发者提升编程效率超 50%。', + displayName: 'code raccoon v1', enabled: true, - id: 'deepseek-coder-33B-instruct', + id: 'code-raccoon-v1', type: 'chat', }, +*/ { + contextWindowTokens: 8000, description: - '代码小浣熊是基于商汤大语言模型的软件智能研发助手,覆盖软件需求分析、架构设计、代码编写、软件测试等环节,满足用户代码编写、编程学习等各类需求。代码小浣熊支持 Python、Java、JavaScript、C++、Go、SQL 等 90+主流编程语言和 VS Code、IntelliJ IDEA 等主流 IDE。在实际应用中,代码小浣熊可帮助开发者提升编程效率超 50%。', - displayName: 'code raccoon v1', + 'DeepSeek Coder 33B 是一个代码语言模型, 基于 2 万亿数据训练而成,其中 87% 为代码, 13% 为中英文语言。模型引入 16K 窗口大小和填空任务,提供项目级别的代码补全和片段填充功能。', + displayName: 'DeepSeek Coder 33B Instruct', enabled: true, - id: 'code-raccoon-v1', + id: 'deepseek-coder-33B-instruct', type: 'chat', }, { - contextWindowTokens: 40_000, + contextWindowTokens: 32_000, description: 'CodeGeeX4-ALL-9B 是一个多语言代码生成模型,支持包括代码补全和生成、代码解释器、网络搜索、函数调用、仓库级代码问答在内的全面功能,覆盖软件开发的各种场景。是参数少于 10B 的顶尖代码生成模型。', displayName: 'CodeGeeX4 All 9B', diff --git a/src/config/aiModels/minimax.ts b/src/config/aiModels/minimax.ts index 8c4f7f765e13..3dd1674001c5 100644 --- a/src/config/aiModels/minimax.ts +++ b/src/config/aiModels/minimax.ts @@ -1,6 +1,25 @@ import { AIChatModelCard } from '@/types/aiModel'; const minimaxChatModels: AIChatModelCard[] = [ + { + abilities: { + functionCall: true, + vision: true, + }, + contextWindowTokens: 1_000_192, + description: '在 MiniMax-01系列模型中,我们做了大胆创新:首次大规模实现线性注意力机制,传统 Transformer架构不再是唯一的选择。这个模型的参数量高达4560亿,其中单次激活459亿。模型综合性能比肩海外顶尖模型,同时能够高效处理全球最长400万token的上下文,是GPT-4o的32倍,Claude-3.5-Sonnet的20倍。', + displayName: 'MiniMax-Text-01', + enabled: true, + id: 'MiniMax-Text-01', + maxOutput: 1_000_192, + pricing: { + currency: 'CNY', + input: 10, + output: 10, + }, + releasedAt: '2025-01-15', + type: 'chat', + }, { abilities: { functionCall: true, diff --git a/src/config/aiModels/moonshot.ts b/src/config/aiModels/moonshot.ts index ae1990457757..cec5e20385ff 100644 --- a/src/config/aiModels/moonshot.ts +++ b/src/config/aiModels/moonshot.ts @@ -11,6 +11,11 @@ const moonshotChatModels: AIChatModelCard[] = [ displayName: 'Moonshot V1 8K', enabled: true, id: 'moonshot-v1-8k', + pricing: { + currency: 'CNY', + input: 12, + output: 12, + }, type: 'chat', }, { @@ -23,18 +28,85 @@ const moonshotChatModels: AIChatModelCard[] = [ displayName: 'Moonshot V1 32K', enabled: true, id: 'moonshot-v1-32k', + pricing: { + currency: 'CNY', + input: 24, + output: 24, + }, type: 'chat', }, { abilities: { functionCall: true, }, - contextWindowTokens: 128_000, + contextWindowTokens: 131_072, description: 'Moonshot V1 128K 是一款拥有超长上下文处理能力的模型,适用于生成超长文本,满足复杂的生成任务需求,能够处理多达128,000个tokens的内容,非常适合科研、学术和大型文档生成等应用场景。', displayName: 'Moonshot V1 128K', enabled: true, id: 'moonshot-v1-128k', + pricing: { + currency: 'CNY', + input: 60, + output: 60, + }, + type: 'chat', + }, + { + abilities: { + functionCall: true, + vision: true, + }, + contextWindowTokens: 8192, + description: + 'Kimi 视觉模型(包括 moonshot-v1-8k-vision-preview/moonshot-v1-32k-vision-preview/moonshot-v1-128k-vision-preview 等)能够理解图片内容,包括图片文字、图片颜色和物体形状等内容。', + displayName: 'Moonshot V1 8K Vision Preview', + enabled: true, + id: 'moonshot-v1-8k-vision-preview', + pricing: { + currency: 'CNY', + input: 12, + output: 12, + }, + releasedAt: '2025-01-14', + type: 'chat', + }, + { + abilities: { + functionCall: true, + vision: true, + }, + contextWindowTokens: 32_768, + description: + 'Kimi 视觉模型(包括 moonshot-v1-8k-vision-preview/moonshot-v1-32k-vision-preview/moonshot-v1-128k-vision-preview 等)能够理解图片内容,包括图片文字、图片颜色和物体形状等内容。', + displayName: 'Moonshot V1 32K Vision Preview', + enabled: true, + id: 'moonshot-v1-32k-vision-preview', + pricing: { + currency: 'CNY', + input: 24, + output: 24, + }, + releasedAt: '2025-01-14', + type: 'chat', + }, + { + abilities: { + functionCall: true, + vision: true, + }, + contextWindowTokens: 131_072, + description: + 'Kimi 视觉模型(包括 moonshot-v1-8k-vision-preview/moonshot-v1-32k-vision-preview/moonshot-v1-128k-vision-preview 等)能够理解图片内容,包括图片文字、图片颜色和物体形状等内容。', + displayName: 'Moonshot V1 128K Vision Preview', + enabled: true, + id: 'moonshot-v1-128k-vision-preview', + pricing: { + currency: 'CNY', + input: 60, + output: 60, + }, + releasedAt: '2025-01-14', type: 'chat', }, ]; diff --git a/src/config/aiModels/taichu.ts b/src/config/aiModels/taichu.ts index 583c1ab1efa7..81dedf56a25c 100644 --- a/src/config/aiModels/taichu.ts +++ b/src/config/aiModels/taichu.ts @@ -6,10 +6,31 @@ const taichuChatModels: AIChatModelCard[] = [ functionCall: true, }, contextWindowTokens: 32_768, - description: 'Taichu 2.0 基于海量高质数据训练,具有更强的文本理解、内容创作、对话问答等能力', + description: '基于海量高质数据训练,具有更强的文本理解、内容创作、对话问答等能力', displayName: 'Taichu 2.0', enabled: true, id: 'taichu_llm', + pricing: { + currency: 'CNY', + input: 2, + output: 2, + }, + type: 'chat', + }, + { + abilities: { + vision: true, + }, + contextWindowTokens: 4096, + description: '融合了图像理解、知识迁移、逻辑归因等能力,在图文问答领域表现突出', + displayName: 'Taichu 2.0V', + enabled: true, + id: 'taichu2_mm', + pricing: { + currency: 'CNY', + input: 5, + output: 5, + }, type: 'chat', }, ]; diff --git a/src/config/aiModels/upstage.ts b/src/config/aiModels/upstage.ts index f3b378e47148..4595fc04fe8d 100644 --- a/src/config/aiModels/upstage.ts +++ b/src/config/aiModels/upstage.ts @@ -22,7 +22,7 @@ const upstageChatModels: AIChatModelCard[] = [ type: 'chat', }, { - contextWindowTokens: 4096, + contextWindowTokens: 32_768, description: 'Solar Pro 是 Upstage 推出的一款高智能LLM,专注于单GPU的指令跟随能力,IFEval得分80以上。目前支持英语,正式版本计划于2024年11月推出,将扩展语言支持和上下文长度。', displayName: 'Solar Pro', diff --git a/src/config/aiModels/zhipu.ts b/src/config/aiModels/zhipu.ts index 9531605cc33c..57898d22efaa 100644 --- a/src/config/aiModels/zhipu.ts +++ b/src/config/aiModels/zhipu.ts @@ -1,6 +1,19 @@ import { AIChatModelCard } from '@/types/aiModel'; const zhipuChatModels: AIChatModelCard[] = [ + { + contextWindowTokens: 16_384, + description: 'GLM-Zero-Preview具备强大的复杂推理能力,在逻辑推理、数学、编程等领域表现优异。', + displayName: 'GLM-Zero-Preview', + enabled: true, + id: 'glm-zero-preview', + pricing: { + currency: 'CNY', + input: 10, + output: 10, + }, + type: 'chat', + }, { abilities: { functionCall: true, diff --git a/src/config/modelProviders/ai21.ts b/src/config/modelProviders/ai21.ts index 28dfedcb182d..743a486fa5f8 100644 --- a/src/config/modelProviders/ai21.ts +++ b/src/config/modelProviders/ai21.ts @@ -29,12 +29,10 @@ const Ai21: ModelProviderCard = { checkModel: 'jamba-1.5-mini', description: 'AI21 Labs 为企业构建基础模型和人工智能系统,加速生成性人工智能在生产中的应用。', id: 'ai21', - modelList: { showModelFetcher: true }, modelsUrl: 'https://docs.ai21.com/reference', name: 'Ai21Labs', settings: { sdkType: 'openai', - showModelFetcher: true, }, url: 'https://studio.ai21.com', }; diff --git a/src/config/modelProviders/ai360.ts b/src/config/modelProviders/ai360.ts index b0a8712287c6..d1a686733ad2 100644 --- a/src/config/modelProviders/ai360.ts +++ b/src/config/modelProviders/ai360.ts @@ -4,59 +4,55 @@ import { ModelProviderCard } from '@/types/llm'; const Ai360: ModelProviderCard = { chatModels: [ { - contextWindowTokens: 8192, + contextWindowTokens: 8000, description: - '360GPT2 Pro 是 360 公司推出的高级自然语言处理模型,具备卓越的文本生成和理解能力,尤其在生成与创作领域表现出色,能够处理复杂的语言转换和角色演绎任务。', - displayName: '360GPT2 Pro', + '360gpt2-o1 使用树搜索构建思维链,并引入了反思机制,使用强化学习训练,模型具备自我反思与纠错的能力。', + displayName: '360GPT2 o1', enabled: true, - id: '360gpt2-pro', - maxOutput: 7000, + id: '360gpt2-o1', pricing: { currency: 'CNY', - input: 5, - output: 5, + input: 20, + output: 50, }, }, { - contextWindowTokens: 8192, + contextWindowTokens: 8000, description: - '360GPT Pro 作为 360 AI 模型系列的重要成员,以高效的文本处理能力满足多样化的自然语言应用场景,支持长文本理解和多轮对话等功能。', - displayName: '360GPT Pro', + '360智脑系列效果最好的主力千亿级大模型,广泛适用于各领域复杂任务场景。', + displayName: '360GPT2 Pro', enabled: true, - functionCall: true, - id: '360gpt-pro', - maxOutput: 7000, + id: '360gpt2-pro', pricing: { currency: 'CNY', - input: 5, + input: 2, output: 5, }, }, { - contextWindowTokens: 8192, + contextWindowTokens: 8000, description: - '360GPT Turbo 提供强大的计算和对话能力,具备出色的语义理解和生成效率,是企业和开发者理想的智能助理解决方案。', - displayName: '360GPT Turbo', + '360智脑系列效果最好的主力千亿级大模型,广泛适用于各领域复杂任务场景。', + displayName: '360GPT Pro', enabled: true, - id: '360gpt-turbo', - maxOutput: 7000, + functionCall: true, + id: '360gpt-pro', pricing: { currency: 'CNY', input: 2, - output: 2, + output: 5, }, }, { - contextWindowTokens: 8192, + contextWindowTokens: 7000, description: - '360GPT Turbo Responsibility 8K 强调语义安全和责任导向,专为对内容安全有高度要求的应用场景设计,确保用户体验的准确性与稳健性。', - displayName: '360GPT Turbo Responsibility 8K', + '兼顾性能和效果的百亿级大模型,适合对性能/成本要求较高 的场景。', + displayName: '360GPT Turbo', enabled: true, - id: '360gpt-turbo-responsibility-8k', - maxOutput: 2048, + id: '360gpt-turbo', pricing: { currency: 'CNY', - input: 2, + input: 1, output: 2, }, }, diff --git a/src/config/modelProviders/anthropic.ts b/src/config/modelProviders/anthropic.ts index 90f615533366..1e8427b011f5 100644 --- a/src/config/modelProviders/anthropic.ts +++ b/src/config/modelProviders/anthropic.ts @@ -133,6 +133,7 @@ const Anthropic: ModelProviderCard = { 'Anthropic 是一家专注于人工智能研究和开发的公司,提供了一系列先进的语言模型,如 Claude 3.5 Sonnet、Claude 3 Sonnet、Claude 3 Opus 和 Claude 3 Haiku。这些模型在智能、速度和成本之间取得了理想的平衡,适用于从企业级工作负载到快速响应的各种应用场景。Claude 3.5 Sonnet 作为其最新模型,在多项评估中表现优异,同时保持了较高的性价比。', enabled: true, id: 'anthropic', + modelList: { showModelFetcher: true }, modelsUrl: 'https://docs.anthropic.com/en/docs/about-claude/models#model-names', name: 'Anthropic', proxyUrl: { diff --git a/src/config/modelProviders/giteeai.ts b/src/config/modelProviders/giteeai.ts index dde54eedc4c0..641eb71fa973 100644 --- a/src/config/modelProviders/giteeai.ts +++ b/src/config/modelProviders/giteeai.ts @@ -6,28 +6,14 @@ const GiteeAI: ModelProviderCard = { { contextWindowTokens: 16_000, description: - 'Qwen2.5-72B-Instruct 支持 16k 上下文, 生成长文本超过 8K 。支持 function call 与外部系统无缝交互,极大提升了灵活性和扩展性。模型知识明显增加,并且大大提高了编码和数学能力, 多语言支持超过 29 种', + 'Qwen2.5-72B-Instruct 支持 16k 上下文, 生成长文本超过 8K 。支持 function call 与外部系统无缝交互,极大提升了灵活性和扩展性。模型知识明显增加,并且大大提高了编码和数学能力, 多语言支持超过 29 种', displayName: 'Qwen2.5 72B Instruct', enabled: true, functionCall: true, id: 'Qwen2.5-72B-Instruct', }, { - description: - 'Qwen2.5-Coder-32B-Instruct 是一款专为代码生成、代码理解和高效开发场景设计的大型语言模型,采用了业界领先的32B参数规模,能够满足多样化的编程需求。', - displayName: 'Qwen2.5 Coder 32B Instruct', - enabled: true, - id: 'Qwen2.5-Coder-32B-Instruct', - }, - { - description: - 'Qwen2.5-7B-Instruct 是一款 70 亿参数的大语言模型,支持 function call 与外部系统无缝交互,极大提升了灵活性和扩展性。优化中文和多语言场景,支持智能问答、内容生成等应用。', - displayName: 'Qwen2.5 7B Instruct', - enabled: true, - functionCall: true, - id: 'Qwen2.5-7B-Instruct', - }, - { + contextWindowTokens: 32_000, description: 'Qwen2.5-32B-Instruct 是一款 320 亿参数的大语言模型,性能表现均衡,优化中文和多语言场景,支持智能问答、内容生成等应用。', displayName: 'Qwen2.5 32B Instruct', @@ -35,6 +21,7 @@ const GiteeAI: ModelProviderCard = { id: 'Qwen2.5-32B-Instruct', }, { + contextWindowTokens: 24_000, description: 'Qwen2.5-14B-Instruct 是一款 140 亿参数的大语言模型,性能表现优秀,优化中文和多语言场景,支持智能问答、内容生成等应用。', displayName: 'Qwen2.5 14B Instruct', @@ -42,35 +29,71 @@ const GiteeAI: ModelProviderCard = { id: 'Qwen2.5-14B-Instruct', }, { - contextWindowTokens: 6000, + contextWindowTokens: 32_000, description: - 'Qwen2 是 Qwen 模型的最新系列,支持 128k 上下文,对比当前最优的开源模型,Qwen2-72B 在自然语言理解、知识、代码、数学及多语言等多项能力上均显著超越当前领先的模型。', + 'Qwen2.5-7B-Instruct 是一款 70 亿参数的大语言模型,支持 function call 与外部系统无缝交互,极大提升了灵活性和扩展性。优化中文和多语言场景,支持智能问答、内容生成等应用。', + displayName: 'Qwen2.5 7B Instruct', + enabled: true, + functionCall: true, + id: 'Qwen2.5-7B-Instruct', + }, + { + contextWindowTokens: 32_000, + description: + 'Qwen2 是 Qwen 模型的最新系列,对比当前最优的开源模型,Qwen2-72B 在自然语言理解、知识、代码、数学及多语言等多项能力上均显著超越当前领先的模型。', displayName: 'Qwen2 72B Instruct', id: 'Qwen2-72B-Instruct', }, { - contextWindowTokens: 32_000, + contextWindowTokens: 24_000, description: 'Qwen2 是 Qwen 模型的最新系列,能够超越同等规模的最优开源模型甚至更大规模的模型,Qwen2 7B 在多个评测上取得显著的优势,尤其是代码及中文理解上。', displayName: 'Qwen2 7B Instruct', id: 'Qwen2-7B-Instruct', }, { + contextWindowTokens: 32_000, description: - 'InternVL2-8B 是一款强大的视觉语言模型,支持图像与文本的多模态处理,能够精确识别图像内容并生成相关描述或回答。', - displayName: 'InternVL2 8B', + 'Qwen2.5-Coder-32B-Instruct 是一款专为代码生成、代码理解和高效开发场景设计的大型语言模型,采用了业界领先的32B参数规模,能够满足多样化的编程需求。', + displayName: 'Qwen2.5 Coder 32B Instruct', enabled: true, - id: 'InternVL2-8B', + id: 'Qwen2.5-Coder-32B-Instruct', + }, + { + contextWindowTokens: 24_000, + description: + 'Qwen2.5-Coder-14B-Instruct 是一款基于大规模预训练的编程指令模型,具备强大的代码理解和生成能力,能够高效地处理各种编程任务,特别适合智能代码编写、自动化脚本生成和编程问题解答。', + displayName: 'Qwen2.5 Coder 14B Instruct', + enabled: true, + id: 'Qwen2.5-Coder-14B-Instruct', + }, + { + contextWindowTokens: 32_000, + description: + 'Qwen2-VL-72B是一款强大的视觉语言模型,支持图像与文本的多模态处理,能够精确识别图像内容并生成相关描述或回答。', + displayName: 'Qwen2 VL 72B', + enabled: true, + id: 'Qwen2-VL-72B', vision: true, }, { + contextWindowTokens: 32_000, description: - 'InternVL2.5-26B 是一款强大的视觉语言模型,支持图像与文本的多模态处理,能够精确识别图像内容并生成相关描述或回答。', + 'InternVL2.5-26B是一款强大的视觉语言模型,支持图像与文本的多模态处理,能够精确识别图像内容并生成相关描述或回答。', displayName: 'InternVL2.5 26B', enabled: true, id: 'InternVL2.5-26B', vision: true, }, + { + contextWindowTokens: 32_000, + description: + 'InternVL2-8B 是一款强大的视觉语言模型,支持图像与文本的多模态处理,能够精确识别图像内容并生成相关描述或回答。', + displayName: 'InternVL2 8B', + enabled: true, + id: 'InternVL2-8B', + vision: true, + }, { contextWindowTokens: 32_000, description: @@ -82,28 +105,31 @@ const GiteeAI: ModelProviderCard = { { contextWindowTokens: 4000, description: - 'Yi-1.5-34B 在保持原系列模型优秀的通用语言能力的前提下,通过增量训练 5 千亿高质量 token,大幅提高了数学逻辑、代码能力。', + 'Yi-1.5-34B-Chat 在保持原系列模型优秀的通用语言能力的前提下,通过增量训练 5 千亿高质量 token,大幅提高了数学逻辑、代码能力。', displayName: 'Yi 34B Chat', enabled: true, id: 'Yi-34B-Chat', }, +/* + // not compatible with OpenAI SDK { - contextWindowTokens: 8000, description: - 'DeepSeek Coder 33B 是一个代码语言模型, 基于 2 万亿数据训练而成,其中 87% 为代码, 13% 为中英文语言。模型引入 16K 窗口大小和填空任务,提供项目级别的代码补全和片段填充功能。', - displayName: 'DeepSeek Coder 33B Instruct', + '代码小浣熊是基于商汤大语言模型的软件智能研发助手,覆盖软件需求分析、架构设计、代码编写、软件测试等环节,满足用户代码编写、编程学习等各类需求。代码小浣熊支持 Python、Java、JavaScript、C++、Go、SQL 等 90+主流编程语言和 VS Code、IntelliJ IDEA 等主流 IDE。在实际应用中,代码小浣熊可帮助开发者提升编程效率超 50%。', + displayName: 'Code Raccoon v1', enabled: true, - id: 'deepseek-coder-33B-instruct', + id: 'code-raccoon-v1', }, +*/ { + contextWindowTokens: 8000, description: - '代码小浣熊是基于商汤大语言模型的软件智能研发助手,覆盖软件需求分析、架构设计、代码编写、软件测试等环节,满足用户代码编写、编程学习等各类需求。代码小浣熊支持 Python、Java、JavaScript、C++、Go、SQL 等 90+主流编程语言和 VS Code、IntelliJ IDEA 等主流 IDE。在实际应用中,代码小浣熊可帮助开发者提升编程效率超 50%。', - displayName: 'code raccoon v1', + 'DeepSeek Coder 33B 是一个代码语言模型, 基于 2 万亿数据训练而成,其中 87% 为代码, 13% 为中英文语言。模型引入 16K 窗口大小和填空任务,提供项目级别的代码补全和片段填充功能。', + displayName: 'DeepSeek Coder 33B Instruct', enabled: true, - id: 'code-raccoon-v1', + id: 'deepseek-coder-33B-instruct', }, { - contextWindowTokens: 40_000, + contextWindowTokens: 32_000, description: 'CodeGeeX4-ALL-9B 是一个多语言代码生成模型,支持包括代码补全和生成、代码解释器、网络搜索、函数调用、仓库级代码问答在内的全面功能,覆盖软件开发的各种场景。是参数少于 10B 的顶尖代码生成模型。', displayName: 'CodeGeeX4 All 9B', diff --git a/src/config/modelProviders/google.ts b/src/config/modelProviders/google.ts index 1940562b7d42..cc8673413a76 100644 --- a/src/config/modelProviders/google.ts +++ b/src/config/modelProviders/google.ts @@ -273,6 +273,7 @@ const Google: ModelProviderCard = { 'Google 的 Gemini 系列是其最先进、通用的 AI模型,由 Google DeepMind 打造,专为多模态设计,支持文本、代码、图像、音频和视频的无缝理解与处理。适用于从数据中心到移动设备的多种环境,极大提升了AI模型的效率与应用广泛性。', enabled: true, id: 'google', + modelList: { showModelFetcher: true }, modelsUrl: 'https://ai.google.dev/gemini-api/docs/models/gemini', name: 'Google', proxyUrl: { @@ -283,6 +284,7 @@ const Google: ModelProviderCard = { placeholder: 'https://generativelanguage.googleapis.com', }, sdkType: 'google', + showModelFetcher: true, smoothing: { speed: 2, text: true, diff --git a/src/config/modelProviders/hunyuan.ts b/src/config/modelProviders/hunyuan.ts index 684c385b2894..6581c25e9b02 100644 --- a/src/config/modelProviders/hunyuan.ts +++ b/src/config/modelProviders/hunyuan.ts @@ -135,13 +135,11 @@ const Hunyuan: ModelProviderCard = { '由腾讯研发的大语言模型,具备强大的中文创作能力,复杂语境下的逻辑推理能力,以及可靠的任务执行能力', disableBrowserRequest: true, id: 'hunyuan', - modelList: { showModelFetcher: true }, modelsUrl: 'https://cloud.tencent.com/document/product/1729/104753', name: 'Hunyuan', settings: { disableBrowserRequest: true, sdkType: 'openai', - showModelFetcher: true, }, url: 'https://hunyuan.tencent.com', }; diff --git a/src/config/modelProviders/mistral.ts b/src/config/modelProviders/mistral.ts index 330efd7e0b25..4c45f53fa6a9 100644 --- a/src/config/modelProviders/mistral.ts +++ b/src/config/modelProviders/mistral.ts @@ -150,10 +150,12 @@ const Mistral: ModelProviderCard = { description: 'Mistral 提供先进的通用、专业和研究型模型,广泛应用于复杂推理、多语言任务、代码生成等领域,通过功能调用接口,用户可以集成自定义功能,实现特定应用。', id: 'mistral', + modelList: { showModelFetcher: true }, modelsUrl: 'https://docs.mistral.ai/getting-started/models', name: 'Mistral', settings: { sdkType: 'openai', + showModelFetcher: true, }, url: 'https://mistral.ai', }; diff --git a/src/config/modelProviders/moonshot.ts b/src/config/modelProviders/moonshot.ts index 7fbeaa9fa735..272eaebbbbf0 100644 --- a/src/config/modelProviders/moonshot.ts +++ b/src/config/modelProviders/moonshot.ts @@ -35,6 +35,7 @@ const Moonshot: ModelProviderCard = { description: 'Moonshot 是由北京月之暗面科技有限公司推出的开源平台,提供多种自然语言处理模型,应用领域广泛,包括但不限于内容创作、学术研究、智能推荐、医疗诊断等,支持长文本处理和复杂生成任务。', id: 'moonshot', + modelList: { showModelFetcher: true }, modelsUrl: 'https://platform.moonshot.cn/docs/intro', name: 'Moonshot', proxyUrl: { @@ -45,6 +46,7 @@ const Moonshot: ModelProviderCard = { placeholder: 'https://api.moonshot.cn/v1', }, sdkType: 'openai', + showModelFetcher: true, smoothing: { speed: 2, text: true, diff --git a/src/config/modelProviders/spark.ts b/src/config/modelProviders/spark.ts index 74ac52e65ddf..f2a53796d339 100644 --- a/src/config/modelProviders/spark.ts +++ b/src/config/modelProviders/spark.ts @@ -66,12 +66,10 @@ const Spark: ModelProviderCard = { description: '科大讯飞星火大模型提供多领域、多语言的强大 AI 能力,利用先进的自然语言处理技术,构建适用于智能硬件、智慧医疗、智慧金融等多种垂直场景的创新应用。', id: 'spark', - modelList: { showModelFetcher: true }, modelsUrl: 'https://xinghuo.xfyun.cn/spark', name: 'Spark', settings: { sdkType: 'openai', - showModelFetcher: true, smoothing: { speed: 2, text: true, diff --git a/src/config/modelProviders/taichu.ts b/src/config/modelProviders/taichu.ts index cdf1359593aa..42d24e301e01 100644 --- a/src/config/modelProviders/taichu.ts +++ b/src/config/modelProviders/taichu.ts @@ -5,34 +5,39 @@ const Taichu: ModelProviderCard = { chatModels: [ { contextWindowTokens: 32_768, - description: 'Taichu 2.0 基于海量高质数据训练,具有更强的文本理解、内容创作、对话问答等能力', + description: '基于海量高质数据训练,具有更强的文本理解、内容创作、对话问答等能力', displayName: 'Taichu 2.0', enabled: true, functionCall: true, id: 'taichu_llm', + pricing: { + currency: 'CNY', + input: 2, + output: 2, + }, }, - /* - // TODO: Not support for now { - description: - 'Taichu 2.0V 融合了图像理解、知识迁移、逻辑归因等能力,在图文问答领域表现突出', + contextWindowTokens: 4096, + description: '融合了图像理解、知识迁移、逻辑归因等能力,在图文问答领域表现突出', displayName: 'Taichu 2.0V', - id: 'taichu_vqa', - tokens: 4096, + enabled: true, + id: 'taichu2_mm', + pricing: { + currency: 'CNY', + input: 5, + output: 5, + }, vision: true, }, -*/ ], checkModel: 'taichu_llm', description: '中科院自动化研究所和武汉人工智能研究院推出新一代多模态大模型,支持多轮问答、文本创作、图像生成、3D理解、信号分析等全面问答任务,拥有更强的认知、理解、创作能力,带来全新互动体验。', id: 'taichu', - modelList: { showModelFetcher: true }, modelsUrl: 'https://ai-maas.wair.ac.cn/#/doc', name: 'Taichu', settings: { sdkType: 'openai', - showModelFetcher: true, }, url: 'https://ai-maas.wair.ac.cn', }; diff --git a/src/config/modelProviders/upstage.ts b/src/config/modelProviders/upstage.ts index 9ecd018ac7ee..f3ac38b71b48 100644 --- a/src/config/modelProviders/upstage.ts +++ b/src/config/modelProviders/upstage.ts @@ -21,7 +21,7 @@ const Upstage: ModelProviderCard = { id: 'solar-1-mini-chat-ja', }, { - contextWindowTokens: 4096, + contextWindowTokens: 32_768, description: 'Solar Pro 是 Upstage 推出的一款高智能LLM,专注于单GPU的指令跟随能力,IFEval得分80以上。目前支持英语,正式版本计划于2024年11月推出,将扩展语言支持和上下文长度。', displayName: 'Solar Pro', @@ -34,12 +34,10 @@ const Upstage: ModelProviderCard = { description: 'Upstage 专注于为各种商业需求开发AI模型,包括 Solar LLM 和文档 AI,旨在实现工作的人造通用智能(AGI)。通过 Chat API 创建简单的对话代理,并支持功能调用、翻译、嵌入以及特定领域应用。', id: 'upstage', - modelList: { showModelFetcher: true }, modelsUrl: 'https://developers.upstage.ai/docs/getting-started/models', name: 'Upstage', settings: { sdkType: 'openai', - showModelFetcher: true, }, url: 'https://upstage.ai', }; diff --git a/src/config/modelProviders/zeroone.ts b/src/config/modelProviders/zeroone.ts index af3c3e1edba8..e267e503f2eb 100644 --- a/src/config/modelProviders/zeroone.ts +++ b/src/config/modelProviders/zeroone.ts @@ -141,9 +141,13 @@ const ZeroOne: ModelProviderCard = { description: '零一万物致力于推动以人为本的AI 2.0技术革命,旨在通过大语言模型创造巨大的经济和社会价值,并开创新的AI生态与商业模式。', id: 'zeroone', + modelList: { showModelFetcher: true }, modelsUrl: 'https://platform.lingyiwanwu.com/docs#模型与计费', name: '01.AI', - settings: { sdkType: 'openai' }, + settings: { + sdkType: 'openai', + showModelFetcher: true, + }, url: 'https://www.lingyiwanwu.com/', }; diff --git a/src/config/modelProviders/zhipu.ts b/src/config/modelProviders/zhipu.ts index 3af7b39b8d56..738d72c87fa6 100644 --- a/src/config/modelProviders/zhipu.ts +++ b/src/config/modelProviders/zhipu.ts @@ -5,6 +5,18 @@ import { ModelProviderCard } from '@/types/llm'; // ref :https://open.bigmodel.cn/modelcenter/square const ZhiPu: ModelProviderCard = { chatModels: [ + { + contextWindowTokens: 16_384, + description: 'GLM-Zero-Preview具备强大的复杂推理能力,在逻辑推理、数学、编程等领域表现优异。', + displayName: 'GLM-Zero-Preview', + enabled: true, + id: 'glm-zero-preview', + pricing: { + currency: 'CNY', + input: 10, + output: 10, + }, + }, { contextWindowTokens: 128_000, description: 'GLM-4-Flash 是处理简单任务的理想选择,速度最快且免费。', @@ -199,9 +211,13 @@ const ZhiPu: ModelProviderCard = { description: '智谱 AI 提供多模态与语言模型的开放平台,支持广泛的AI应用场景,包括文本处理、图像理解与编程辅助等。', id: 'zhipu', + modelList: { showModelFetcher: true }, modelsUrl: 'https://open.bigmodel.cn/dev/howuse/model', name: 'ZhiPu', - settings: { sdkType: 'openai' }, + settings: { + sdkType: 'openai', + showModelFetcher: true + }, url: 'https://zhipuai.cn', }; diff --git a/src/libs/agent-runtime/ai360/index.ts b/src/libs/agent-runtime/ai360/index.ts index 175ad951040a..efaf1d831e0e 100644 --- a/src/libs/agent-runtime/ai360/index.ts +++ b/src/libs/agent-runtime/ai360/index.ts @@ -1,6 +1,14 @@ import { ModelProvider } from '../types'; import { LobeOpenAICompatibleFactory } from '../utils/openaiCompatibleFactory'; +import { LOBE_DEFAULT_MODEL_LIST } from '@/config/aiModels'; + +export interface Ai360ModelCard { + id: string; + max_tokens: number; + total_tokens: number; +} + export const LobeAi360AI = LobeOpenAICompatibleFactory({ baseURL: 'https://api.360.cn/v1', chatCompletion: { @@ -14,5 +22,21 @@ export const LobeAi360AI = LobeOpenAICompatibleFactory({ debug: { chatCompletion: () => process.env.DEBUG_AI360_CHAT_COMPLETION === '1', }, + models: { + transformModel: (m) => { + const model = m as unknown as Ai360ModelCard; + + return { + contextWindowTokens: model.total_tokens, + enabled: LOBE_DEFAULT_MODEL_LIST.find((m) => model.id.endsWith(m.id))?.enabled || false, + functionCall: model.id === '360gpt-pro', + id: model.id, + maxTokens: + typeof model.max_tokens === 'number' + ? model.max_tokens + : undefined, + }; + }, + }, provider: ModelProvider.Ai360, }); diff --git a/src/libs/agent-runtime/anthropic/index.ts b/src/libs/agent-runtime/anthropic/index.ts index 240fd2a5cdb9..e2a6d2cb29ff 100644 --- a/src/libs/agent-runtime/anthropic/index.ts +++ b/src/libs/agent-runtime/anthropic/index.ts @@ -13,18 +13,28 @@ import { buildAnthropicMessages, buildAnthropicTools } from '../utils/anthropicH import { StreamingResponse } from '../utils/response'; import { AnthropicStream } from '../utils/streams'; +import { LOBE_DEFAULT_MODEL_LIST } from '@/config/aiModels'; +import type { ChatModelCard } from '@/types/llm'; + +export interface AnthropicModelCard { + display_name: string; + id: string; +} + const DEFAULT_BASE_URL = 'https://api.anthropic.com'; export class LobeAnthropicAI implements LobeRuntimeAI { private client: Anthropic; baseURL: string; + apiKey?: string; constructor({ apiKey, baseURL = DEFAULT_BASE_URL, ...res }: ClientOptions = {}) { if (!apiKey) throw AgentRuntimeError.createError(AgentRuntimeErrorType.InvalidProviderAPIKey); this.client = new Anthropic({ apiKey, baseURL, ...res }); this.baseURL = this.client.baseURL; + this.apiKey = apiKey; } async chat(payload: ChatStreamPayload, options?: ChatCompetitionOptions) { @@ -102,6 +112,32 @@ export class LobeAnthropicAI implements LobeRuntimeAI { top_p, } satisfies Anthropic.MessageCreateParams; } + + async models() { + const url = `${this.baseURL}/v1/models`; + const response = await fetch(url, { + headers: { + 'anthropic-version': '2023-06-01', + 'x-api-key': `${this.apiKey}`, + }, + method: 'GET', + }); + const json = await response.json(); + + const modelList: AnthropicModelCard[] = json['data']; + + return modelList + .map((model) => { + return { + displayName: model.display_name, + enabled: LOBE_DEFAULT_MODEL_LIST.find((m) => model.id.endsWith(m.id))?.enabled || false, + functionCall: model.id.toLowerCase().includes('claude-3'), + id: model.id, + vision: model.id.toLowerCase().includes('claude-3') && !model.id.toLowerCase().includes('claude-3-5-haiku'), + }; + }) + .filter(Boolean) as ChatModelCard[]; + } } export default LobeAnthropicAI; diff --git a/src/libs/agent-runtime/baichuan/index.ts b/src/libs/agent-runtime/baichuan/index.ts index 3178977af4ac..160adb7ed2c1 100644 --- a/src/libs/agent-runtime/baichuan/index.ts +++ b/src/libs/agent-runtime/baichuan/index.ts @@ -3,6 +3,17 @@ import OpenAI from 'openai'; import { ChatStreamPayload, ModelProvider } from '../types'; import { LobeOpenAICompatibleFactory } from '../utils/openaiCompatibleFactory'; +import { LOBE_DEFAULT_MODEL_LIST } from '@/config/aiModels'; +import type { ChatModelCard } from '@/types/llm'; + +export interface BaichuanModelCard { + function_call: boolean; + max_input_length: number; + max_tokens: number; + model: string; + model_show_name: string; +} + export const LobeBaichuanAI = LobeOpenAICompatibleFactory({ baseURL: 'https://api.baichuan-ai.com/v1', chatCompletion: { @@ -20,5 +31,22 @@ export const LobeBaichuanAI = LobeOpenAICompatibleFactory({ debug: { chatCompletion: () => process.env.DEBUG_BAICHUAN_CHAT_COMPLETION === '1', }, + models: async ({ client }) => { + const modelsPage = await client.models.list() as any; + const modelList: BaichuanModelCard[] = modelsPage.data; + + return modelList + .map((model) => { + return { + contextWindowTokens: model.max_input_length, + displayName: model.model_show_name, + enabled: LOBE_DEFAULT_MODEL_LIST.find((m) => model.model.endsWith(m.id))?.enabled || false, + functionCall: model.function_call, + id: model.model, + maxTokens: model.max_tokens, + }; + }) + .filter(Boolean) as ChatModelCard[]; + }, provider: ModelProvider.Baichuan, }); diff --git a/src/libs/agent-runtime/deepseek/index.ts b/src/libs/agent-runtime/deepseek/index.ts index fa1527e89c72..29e46db42409 100644 --- a/src/libs/agent-runtime/deepseek/index.ts +++ b/src/libs/agent-runtime/deepseek/index.ts @@ -3,6 +3,12 @@ import OpenAI from 'openai'; import { ChatStreamPayload, ModelProvider } from '../types'; import { LobeOpenAICompatibleFactory } from '../utils/openaiCompatibleFactory'; +import { LOBE_DEFAULT_MODEL_LIST } from '@/config/aiModels'; + +export interface DeepSeekModelCard { + id: string; +} + export const LobeDeepSeekAI = LobeOpenAICompatibleFactory({ baseURL: 'https://api.deepseek.com/v1', chatCompletion: { @@ -28,5 +34,16 @@ export const LobeDeepSeekAI = LobeOpenAICompatibleFactory({ debug: { chatCompletion: () => process.env.DEBUG_DEEPSEEK_CHAT_COMPLETION === '1', }, + models: { + transformModel: (m) => { + const model = m as unknown as DeepSeekModelCard; + + return { + enabled: LOBE_DEFAULT_MODEL_LIST.find((m) => model.id.endsWith(m.id))?.enabled || false, + functionCall: true, + id: model.id, + }; + }, + }, provider: ModelProvider.DeepSeek, }); diff --git a/src/libs/agent-runtime/fireworksai/index.ts b/src/libs/agent-runtime/fireworksai/index.ts index 3f3fe872d8fb..661a2ec555fc 100644 --- a/src/libs/agent-runtime/fireworksai/index.ts +++ b/src/libs/agent-runtime/fireworksai/index.ts @@ -1,10 +1,32 @@ import { ModelProvider } from '../types'; import { LobeOpenAICompatibleFactory } from '../utils/openaiCompatibleFactory'; +import { LOBE_DEFAULT_MODEL_LIST } from '@/config/aiModels'; + +export interface FireworksAIModelCard { + context_length: number; + id: string; + supports_image_input: boolean; + supports_tools: boolean; +} + export const LobeFireworksAI = LobeOpenAICompatibleFactory({ baseURL: 'https://api.fireworks.ai/inference/v1', debug: { chatCompletion: () => process.env.DEBUG_FIREWORKSAI_CHAT_COMPLETION === '1', }, + models: { + transformModel: (m) => { + const model = m as unknown as FireworksAIModelCard; + + return { + contextWindowTokens: model.context_length, + enabled: LOBE_DEFAULT_MODEL_LIST.find((m) => model.id.endsWith(m.id))?.enabled || false, + functionCall: model.supports_tools || model.id.toLowerCase().includes('function'), + id: model.id, + vision: model.supports_image_input, + }; + }, + }, provider: ModelProvider.FireworksAI, }); diff --git a/src/libs/agent-runtime/giteeai/index.ts b/src/libs/agent-runtime/giteeai/index.ts index a84af7571a5f..590a5b65b2f9 100644 --- a/src/libs/agent-runtime/giteeai/index.ts +++ b/src/libs/agent-runtime/giteeai/index.ts @@ -1,10 +1,38 @@ import { ModelProvider } from '../types'; import { LobeOpenAICompatibleFactory } from '../utils/openaiCompatibleFactory'; +import { LOBE_DEFAULT_MODEL_LIST } from '@/config/aiModels'; + +export interface GiteeAIModelCard { + id: string; +} + export const LobeGiteeAI = LobeOpenAICompatibleFactory({ baseURL: 'https://ai.gitee.com/v1', debug: { chatCompletion: () => process.env.DEBUG_GITEE_AI_CHAT_COMPLETION === '1', }, + models: { + transformModel: (m) => { + const functionCallKeywords = [ + 'qwen2.5', + 'glm-4', + ]; + + const visionKeywords = [ + 'internvl', + 'qwen2-vl', + ]; + + const model = m as unknown as GiteeAIModelCard; + + return { + enabled: LOBE_DEFAULT_MODEL_LIST.find((m) => model.id.endsWith(m.id))?.enabled || false, + functionCall: functionCallKeywords.some(keyword => model.id.toLowerCase().includes(keyword)) && !model.id.toLowerCase().includes('qwen2.5-coder'), + id: model.id, + vision: visionKeywords.some(keyword => model.id.toLowerCase().includes(keyword)), + }; + }, + }, provider: ModelProvider.GiteeAI, }); diff --git a/src/libs/agent-runtime/google/index.ts b/src/libs/agent-runtime/google/index.ts index 3354a3a8bf35..fc41ae7311ba 100644 --- a/src/libs/agent-runtime/google/index.ts +++ b/src/libs/agent-runtime/google/index.ts @@ -27,6 +27,16 @@ import { StreamingResponse } from '../utils/response'; import { GoogleGenerativeAIStream, convertIterableToStream } from '../utils/streams'; import { parseDataUri } from '../utils/uriParser'; +import { LOBE_DEFAULT_MODEL_LIST } from '@/config/aiModels'; +import type { ChatModelCard } from '@/types/llm'; + +export interface GoogleModelCard { + displayName: string; + inputTokenLimit: number; + name: string; + outputTokenLimit: number; +} + enum HarmCategory { HARM_CATEGORY_DANGEROUS_CONTENT = 'HARM_CATEGORY_DANGEROUS_CONTENT', HARM_CATEGORY_HARASSMENT = 'HARM_CATEGORY_HARASSMENT', @@ -46,15 +56,19 @@ function getThreshold(model: string): HarmBlockThreshold { return HarmBlockThreshold.BLOCK_NONE; } +const DEFAULT_BASE_URL = 'https://generativelanguage.googleapis.com'; + export class LobeGoogleAI implements LobeRuntimeAI { private client: GoogleGenerativeAI; baseURL?: string; + apiKey?: string; constructor({ apiKey, baseURL }: { apiKey?: string; baseURL?: string } = {}) { if (!apiKey) throw AgentRuntimeError.createError(AgentRuntimeErrorType.InvalidProviderAPIKey); this.client = new GoogleGenerativeAI(apiKey); - this.baseURL = baseURL; + this.baseURL = baseURL || DEFAULT_BASE_URL; + this.apiKey = apiKey; } async chat(rawPayload: ChatStreamPayload, options?: ChatCompetitionOptions) { @@ -123,6 +137,31 @@ export class LobeGoogleAI implements LobeRuntimeAI { } } + async models() { + const url = `${this.baseURL}/v1beta/models?key=${this.apiKey}`; + const response = await fetch(url, { + method: 'GET', + }); + const json = await response.json(); + + const modelList: GoogleModelCard[] = json['models']; + + return modelList + .map((model) => { + const modelName = model.name.replace(/^models\//, ''); + + return { + contextWindowTokens: model.inputTokenLimit + model.outputTokenLimit, + displayName: model.displayName, + enabled: LOBE_DEFAULT_MODEL_LIST.find((m) => modelName.endsWith(m.id))?.enabled || false, + functionCall: modelName.toLowerCase().includes('gemini'), + id: modelName, + vision: modelName.toLowerCase().includes('vision') || modelName.toLowerCase().includes('gemini') && !modelName.toLowerCase().includes('gemini-1.0'), + }; + }) + .filter(Boolean) as ChatModelCard[]; + } + private buildPayload(payload: ChatStreamPayload) { const system_message = payload.messages.find((m) => m.role === 'system'); const user_messages = payload.messages.filter((m) => m.role !== 'system'); diff --git a/src/libs/agent-runtime/groq/index.ts b/src/libs/agent-runtime/groq/index.ts index de6700fe7a8a..473255acbd98 100644 --- a/src/libs/agent-runtime/groq/index.ts +++ b/src/libs/agent-runtime/groq/index.ts @@ -2,6 +2,13 @@ import { AgentRuntimeErrorType } from '../error'; import { ModelProvider } from '../types'; import { LobeOpenAICompatibleFactory } from '../utils/openaiCompatibleFactory'; +import { LOBE_DEFAULT_MODEL_LIST } from '@/config/aiModels'; + +export interface GroqModelCard { + context_window: number; + id: string; +} + export const LobeGroq = LobeOpenAICompatibleFactory({ baseURL: 'https://api.groq.com/openai/v1', chatCompletion: { @@ -24,5 +31,27 @@ export const LobeGroq = LobeOpenAICompatibleFactory({ debug: { chatCompletion: () => process.env.DEBUG_GROQ_CHAT_COMPLETION === '1', }, + models: { + transformModel: (m) => { + const functionCallKeywords = [ + 'tool', + 'llama-3.3', + 'llama-3.1', + 'llama3-', + 'mixtral-8x7b-32768', + 'gemma2-9b-it', + ]; + + const model = m as unknown as GroqModelCard; + + return { + contextWindowTokens: model.context_window, + enabled: LOBE_DEFAULT_MODEL_LIST.find((m) => model.id.endsWith(m.id))?.enabled || false, + functionCall: functionCallKeywords.some(keyword => model.id.toLowerCase().includes(keyword)), + id: model.id, + vision: model.id.toLowerCase().includes('vision'), + }; + }, + }, provider: ModelProvider.Groq, }); diff --git a/src/libs/agent-runtime/huggingface/index.ts b/src/libs/agent-runtime/huggingface/index.ts index 0739830f82fd..c5b6d3cf59d1 100644 --- a/src/libs/agent-runtime/huggingface/index.ts +++ b/src/libs/agent-runtime/huggingface/index.ts @@ -6,6 +6,14 @@ import { ModelProvider } from '../types'; import { LobeOpenAICompatibleFactory } from '../utils/openaiCompatibleFactory'; import { convertIterableToStream } from '../utils/streams'; +import { LOBE_DEFAULT_MODEL_LIST } from '@/config/aiModels'; +import type { ChatModelCard } from '@/types/llm'; + +export interface HuggingFaceModelCard { + id: string; + tags: string[]; +} + export const LobeHuggingFaceAI = LobeOpenAICompatibleFactory({ chatCompletion: { handleStreamBizErrorType: (error) => { @@ -47,5 +55,34 @@ export const LobeHuggingFaceAI = LobeOpenAICompatibleFactory({ debug: { chatCompletion: () => process.env.DEBUG_HUGGINGFACE_CHAT_COMPLETION === '1', }, + models: async () => { + const visionKeywords = [ + 'image-text-to-text', + 'multimodal', + 'vision', + ]; + + // ref: https://huggingface.co/docs/hub/api + const url = 'https://huggingface.co/api/models'; + const response = await fetch(url, { + method: 'GET', + }); + const json = await response.json(); + + const modelList: HuggingFaceModelCard[] = json; + + return modelList + .map((model) => { + return { + enabled: LOBE_DEFAULT_MODEL_LIST.find((m) => model.id.endsWith(m.id))?.enabled || false, + functionCall: model.tags.some(tag => tag.toLowerCase().includes('function-calling')), + id: model.id, + vision: model.tags.some(tag => + visionKeywords.some(keyword => tag.toLowerCase().includes(keyword)) + ), + }; + }) + .filter(Boolean) as ChatModelCard[]; + }, provider: ModelProvider.HuggingFace, }); diff --git a/src/libs/agent-runtime/internlm/index.ts b/src/libs/agent-runtime/internlm/index.ts index 3dfaf0edda41..0c590ee4d46d 100644 --- a/src/libs/agent-runtime/internlm/index.ts +++ b/src/libs/agent-runtime/internlm/index.ts @@ -1,6 +1,12 @@ import { ModelProvider } from '../types'; import { LobeOpenAICompatibleFactory } from '../utils/openaiCompatibleFactory'; +import { LOBE_DEFAULT_MODEL_LIST } from '@/config/aiModels'; + +export interface InternLMModelCard { + id: string; +} + export const LobeInternLMAI = LobeOpenAICompatibleFactory({ baseURL: 'https://internlm-chat.intern-ai.org.cn/puyu/api/v1', chatCompletion: { @@ -14,5 +20,16 @@ export const LobeInternLMAI = LobeOpenAICompatibleFactory({ debug: { chatCompletion: () => process.env.DEBUG_INTERNLM_CHAT_COMPLETION === '1', }, + models: { + transformModel: (m) => { + const model = m as unknown as InternLMModelCard; + + return { + enabled: LOBE_DEFAULT_MODEL_LIST.find((m) => model.id.endsWith(m.id))?.enabled || false, + functionCall: true, + id: model.id, + }; + }, + }, provider: ModelProvider.InternLM, }); diff --git a/src/libs/agent-runtime/minimax/index.ts b/src/libs/agent-runtime/minimax/index.ts index ab43b0aff9ff..6778951558d3 100644 --- a/src/libs/agent-runtime/minimax/index.ts +++ b/src/libs/agent-runtime/minimax/index.ts @@ -1,10 +1,10 @@ import { ModelProvider } from '../types'; import { LobeOpenAICompatibleFactory } from '../utils/openaiCompatibleFactory'; -import Minimax from '@/config/modelProviders/minimax'; +import minimaxChatModels from '@/config/aiModels/minimax'; export const getMinimaxMaxOutputs = (modelId: string): number | undefined => { - const model = Minimax.chatModels.find(model => model.id === modelId); + const model = minimaxChatModels.find(model => model.id === modelId); return model ? model.maxOutput : undefined; }; diff --git a/src/libs/agent-runtime/mistral/index.ts b/src/libs/agent-runtime/mistral/index.ts index 73fb9d0461c1..3c76a0d34a3a 100644 --- a/src/libs/agent-runtime/mistral/index.ts +++ b/src/libs/agent-runtime/mistral/index.ts @@ -1,6 +1,18 @@ import { ModelProvider } from '../types'; import { LobeOpenAICompatibleFactory } from '../utils/openaiCompatibleFactory'; +import { LOBE_DEFAULT_MODEL_LIST } from '@/config/aiModels'; + +export interface MistralModelCard { + capabilities: { + function_calling: boolean; + vision: boolean; + }; + description: string; + id: string; + max_context_length: number; +} + export const LobeMistralAI = LobeOpenAICompatibleFactory({ baseURL: 'https://api.mistral.ai/v1', chatCompletion: { @@ -18,5 +30,19 @@ export const LobeMistralAI = LobeOpenAICompatibleFactory({ debug: { chatCompletion: () => process.env.DEBUG_MISTRAL_CHAT_COMPLETION === '1', }, + models: { + transformModel: (m) => { + const model = m as unknown as MistralModelCard; + + return { + contextWindowTokens: model.max_context_length, + description: model.description, + enabled: LOBE_DEFAULT_MODEL_LIST.find((m) => model.id.endsWith(m.id))?.enabled || false, + functionCall: model.capabilities.function_calling, + id: model.id, + vision: model.capabilities.vision, + }; + }, + }, provider: ModelProvider.Mistral, }); diff --git a/src/libs/agent-runtime/moonshot/index.ts b/src/libs/agent-runtime/moonshot/index.ts index 28c976d9dcf5..9bb015e9e91e 100644 --- a/src/libs/agent-runtime/moonshot/index.ts +++ b/src/libs/agent-runtime/moonshot/index.ts @@ -3,6 +3,12 @@ import OpenAI from 'openai'; import { ChatStreamPayload, ModelProvider } from '../types'; import { LobeOpenAICompatibleFactory } from '../utils/openaiCompatibleFactory'; +import { LOBE_DEFAULT_MODEL_LIST } from '@/config/aiModels'; + +export interface MoonshotModelCard { + id: string; +} + export const LobeMoonshotAI = LobeOpenAICompatibleFactory({ baseURL: 'https://api.moonshot.cn/v1', chatCompletion: { @@ -18,5 +24,17 @@ export const LobeMoonshotAI = LobeOpenAICompatibleFactory({ debug: { chatCompletion: () => process.env.DEBUG_MOONSHOT_CHAT_COMPLETION === '1', }, + models: { + transformModel: (m) => { + const model = m as unknown as MoonshotModelCard; + + return { + enabled: LOBE_DEFAULT_MODEL_LIST.find((m) => model.id.endsWith(m.id))?.enabled || false, + functionCall: true, + id: model.id, + vision: model.id.toLowerCase().includes('vision'), + }; + }, + }, provider: ModelProvider.Moonshot, }); diff --git a/src/libs/agent-runtime/qwen/index.ts b/src/libs/agent-runtime/qwen/index.ts index 0a695b46fc90..0d6a7dfc4b6a 100644 --- a/src/libs/agent-runtime/qwen/index.ts +++ b/src/libs/agent-runtime/qwen/index.ts @@ -3,6 +3,12 @@ import { LobeOpenAICompatibleFactory } from '../utils/openaiCompatibleFactory'; import { QwenAIStream } from '../utils/streams'; +import { LOBE_DEFAULT_MODEL_LIST } from '@/config/aiModels'; + +export interface QwenModelCard { + id: string; +} + /* QwenEnableSearchModelSeries: An array of Qwen model series that support the enable_search parameter. Currently, enable_search is only supported on Qwen commercial series, excluding Qwen-VL and Qwen-Long series. @@ -60,6 +66,25 @@ export const LobeQwenAI = LobeOpenAICompatibleFactory({ }, debug: { chatCompletion: () => process.env.DEBUG_QWEN_CHAT_COMPLETION === '1', + }, + models: { + transformModel: (m) => { + const functionCallKeywords = [ + 'qwen-max', + 'qwen-plus', + 'qwen-turbo', + 'qwen2.5', + ]; + + const model = m as unknown as QwenModelCard; + + return { + enabled: LOBE_DEFAULT_MODEL_LIST.find((m) => model.id.endsWith(m.id))?.enabled || false, + functionCall: functionCallKeywords.some(keyword => model.id.toLowerCase().includes(keyword)), + id: model.id, + vision: model.id.toLowerCase().includes('vl'), + }; + }, }, provider: ModelProvider.Qwen, }); diff --git a/src/libs/agent-runtime/sensenova/index.ts b/src/libs/agent-runtime/sensenova/index.ts index f551847a693c..050f6b09922e 100644 --- a/src/libs/agent-runtime/sensenova/index.ts +++ b/src/libs/agent-runtime/sensenova/index.ts @@ -1,6 +1,13 @@ import { ModelProvider } from '../types'; import { LobeOpenAICompatibleFactory } from '../utils/openaiCompatibleFactory'; +import { LOBE_DEFAULT_MODEL_LIST } from '@/config/aiModels'; +import type { ChatModelCard } from '@/types/llm'; + +export interface SenseNovaModelCard { + id: string; +} + export const LobeSenseNovaAI = LobeOpenAICompatibleFactory({ baseURL: 'https://api.sensenova.cn/compatible-mode/v1', chatCompletion: { @@ -25,5 +32,26 @@ export const LobeSenseNovaAI = LobeOpenAICompatibleFactory({ debug: { chatCompletion: () => process.env.DEBUG_SENSENOVA_CHAT_COMPLETION === '1', }, + models: async ({ client }) => { + const functionCallKeywords = [ + 'sensechat-5', + ]; + + client.baseURL = 'https://api.sensenova.cn/v1/llm'; + + const modelsPage = await client.models.list() as any; + const modelList: SenseNovaModelCard[] = modelsPage.data; + + return modelList + .map((model) => { + return { + enabled: LOBE_DEFAULT_MODEL_LIST.find((m) => model.id.endsWith(m.id))?.enabled || false, + functionCall: functionCallKeywords.some(keyword => model.id.toLowerCase().includes(keyword)), + id: model.id, + vision: model.id.toLowerCase().includes('vision'), + }; + }) + .filter(Boolean) as ChatModelCard[]; + }, provider: ModelProvider.SenseNova, }); diff --git a/src/libs/agent-runtime/siliconcloud/index.ts b/src/libs/agent-runtime/siliconcloud/index.ts index edc28f455e0f..bf0bd65891b2 100644 --- a/src/libs/agent-runtime/siliconcloud/index.ts +++ b/src/libs/agent-runtime/siliconcloud/index.ts @@ -1,6 +1,12 @@ import { ModelProvider } from '../types'; import { LobeOpenAICompatibleFactory } from '../utils/openaiCompatibleFactory'; +import { LOBE_DEFAULT_MODEL_LIST } from '@/config/aiModels'; + +export interface SiliconCloudModelCard { + id: string; +} + export const LobeSiliconCloudAI = LobeOpenAICompatibleFactory({ baseURL: 'https://api.siliconflow.cn/v1', chatCompletion: { @@ -14,5 +20,33 @@ export const LobeSiliconCloudAI = LobeOpenAICompatibleFactory({ debug: { chatCompletion: () => process.env.DEBUG_SILICONCLOUD_CHAT_COMPLETION === '1', }, + models: { + transformModel: (m) => { + const functionCallKeywords = [ + 'qwen/qwen2.5', + 'thudm/glm-4', + 'deepseek-ai/deepSeek', + 'internlm/internlm2_5', + 'meta-llama/meta-llama-3.1', + 'meta-llama/meta-llama-3.3', + ]; + + const visionKeywords = [ + 'opengvlab/internvl', + 'qwen/qwen2-vl', + 'teleai/telemm', + 'deepseek-ai/deepseek-vl', + ]; + + const model = m as unknown as SiliconCloudModelCard; + + return { + enabled: LOBE_DEFAULT_MODEL_LIST.find((m) => model.id.endsWith(m.id))?.enabled || false, + functionCall: functionCallKeywords.some(keyword => model.id.toLowerCase().includes(keyword)), + id: model.id, + vision: visionKeywords.some(keyword => model.id.toLowerCase().includes(keyword)), + }; + }, + }, provider: ModelProvider.SiliconCloud, }); diff --git a/src/libs/agent-runtime/stepfun/index.ts b/src/libs/agent-runtime/stepfun/index.ts index 4ae98b6fe3c7..2078cbc3c3c6 100644 --- a/src/libs/agent-runtime/stepfun/index.ts +++ b/src/libs/agent-runtime/stepfun/index.ts @@ -1,6 +1,12 @@ import { ModelProvider } from '../types'; import { LobeOpenAICompatibleFactory } from '../utils/openaiCompatibleFactory'; +import { LOBE_DEFAULT_MODEL_LIST } from '@/config/aiModels'; + +export interface StepfunModelCard { + id: string; +} + export const LobeStepfunAI = LobeOpenAICompatibleFactory({ baseURL: 'https://api.stepfun.com/v1', chatCompletion: { @@ -14,5 +20,24 @@ export const LobeStepfunAI = LobeOpenAICompatibleFactory({ debug: { chatCompletion: () => process.env.DEBUG_STEPFUN_CHAT_COMPLETION === '1', }, + models: { + transformModel: (m) => { + // ref: https://platform.stepfun.com/docs/llm/modeloverview + const functionCallKeywords = [ + 'step-1-', + 'step-2-', + 'step-1v-', + ]; + + const model = m as unknown as StepfunModelCard; + + return { + enabled: LOBE_DEFAULT_MODEL_LIST.find((m) => model.id.endsWith(m.id))?.enabled || false, + functionCall: functionCallKeywords.some(keyword => model.id.toLowerCase().includes(keyword)), + id: model.id, + vision: model.id.toLowerCase().includes('v'), + }; + }, + }, provider: ModelProvider.Stepfun, }); diff --git a/src/libs/agent-runtime/xai/index.ts b/src/libs/agent-runtime/xai/index.ts index ed52caa342b4..5602869e4351 100644 --- a/src/libs/agent-runtime/xai/index.ts +++ b/src/libs/agent-runtime/xai/index.ts @@ -1,10 +1,28 @@ import { ModelProvider } from '../types'; import { LobeOpenAICompatibleFactory } from '../utils/openaiCompatibleFactory'; +import { LOBE_DEFAULT_MODEL_LIST } from '@/config/aiModels'; + +export interface XAIModelCard { + id: string; +} + export const LobeXAI = LobeOpenAICompatibleFactory({ baseURL: 'https://api.x.ai/v1', debug: { chatCompletion: () => process.env.DEBUG_XAI_CHAT_COMPLETION === '1', }, + models: { + transformModel: (m) => { + const model = m as unknown as XAIModelCard; + + return { + enabled: LOBE_DEFAULT_MODEL_LIST.find((m) => model.id.endsWith(m.id))?.enabled || false, + functionCall: true, + id: model.id, + vision: model.id.toLowerCase().includes('vision'), + }; + }, + }, provider: ModelProvider.XAI, }); diff --git a/src/libs/agent-runtime/zeroone/index.ts b/src/libs/agent-runtime/zeroone/index.ts index 18c0f0a9d5d7..fb8ab88c550a 100644 --- a/src/libs/agent-runtime/zeroone/index.ts +++ b/src/libs/agent-runtime/zeroone/index.ts @@ -1,11 +1,28 @@ import { ModelProvider } from '../types'; import { LobeOpenAICompatibleFactory } from '../utils/openaiCompatibleFactory'; +import { LOBE_DEFAULT_MODEL_LIST } from '@/config/aiModels'; + +export interface ZeroOneModelCard { + id: string; +} + export const LobeZeroOneAI = LobeOpenAICompatibleFactory({ baseURL: 'https://api.lingyiwanwu.com/v1', debug: { chatCompletion: () => process.env.DEBUG_ZEROONE_CHAT_COMPLETION === '1', }, + models: { + transformModel: (m) => { + const model = m as unknown as ZeroOneModelCard; + return { + enabled: LOBE_DEFAULT_MODEL_LIST.find((m) => model.id.endsWith(m.id))?.enabled || false, + functionCall: model.id.toLowerCase().includes('fc'), + id: model.id, + vision: model.id.toLowerCase().includes('vision'), + }; + }, + }, provider: ModelProvider.ZeroOne, }); diff --git a/src/libs/agent-runtime/zhipu/index.ts b/src/libs/agent-runtime/zhipu/index.ts index b49060e0166f..3003fe0d9374 100644 --- a/src/libs/agent-runtime/zhipu/index.ts +++ b/src/libs/agent-runtime/zhipu/index.ts @@ -3,6 +3,15 @@ import OpenAI from 'openai'; import { ChatStreamPayload, ModelProvider } from '../types'; import { LobeOpenAICompatibleFactory } from '../utils/openaiCompatibleFactory'; +import { LOBE_DEFAULT_MODEL_LIST } from '@/config/aiModels'; +import type { ChatModelCard } from '@/types/llm'; + +export interface ZhipuModelCard { + description: string; + modelCode: string; + modelName: string; +} + export const LobeZhipuAI = LobeOpenAICompatibleFactory({ baseURL: 'https://open.bigmodel.cn/api/paas/v4', chatCompletion: { @@ -25,8 +34,34 @@ export const LobeZhipuAI = LobeOpenAICompatibleFactory({ }), }) as OpenAI.ChatCompletionCreateParamsStreaming, }, + constructorOptions: { + defaultHeaders: { + 'Bigmodel-Organization': 'lobehub', + 'Bigmodel-project': 'lobechat', + }, + }, debug: { chatCompletion: () => process.env.DEBUG_ZHIPU_CHAT_COMPLETION === '1', }, + models: async ({ client }) => { + // ref: https://open.bigmodel.cn/console/modelcenter/square + client.baseURL = 'https://open.bigmodel.cn/api/fine-tuning/model_center/list?pageSize=100&pageNum=1'; + + const modelsPage = await client.models.list() as any; + const modelList: ZhipuModelCard[] = modelsPage.body.rows; + + return modelList + .map((model) => { + return { + description: model.description, + displayName: model.modelName, + enabled: LOBE_DEFAULT_MODEL_LIST.find((m) => model.modelCode.endsWith(m.id))?.enabled || false, + functionCall: model.modelCode.toLowerCase().includes('glm-4') && !model.modelCode.toLowerCase().includes('glm-4v'), + id: model.modelCode, + vision: model.modelCode.toLowerCase().includes('glm-4v'), + }; + }) + .filter(Boolean) as ChatModelCard[]; + }, provider: ModelProvider.ZhiPu, });