From c84e84f7c9257c288a386ee1d95757b83910efb8 Mon Sep 17 00:00:00 2001 From: Zhijie He Date: Mon, 6 Jan 2025 23:01:02 +0800 Subject: [PATCH 01/21] =?UTF-8?q?=F0=9F=92=84=20style:=20add=20ModelFetche?= =?UTF-8?q?r=20for=20supported=20provider?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/config/modelProviders/ai21.ts | 2 - src/config/modelProviders/ai360.ts | 48 ++++++------ src/config/modelProviders/anthropic.ts | 1 - src/config/modelProviders/baichuan.ts | 2 - src/config/modelProviders/fireworksai.ts | 2 - src/config/modelProviders/giteeai.ts | 92 ++++++++++++++--------- src/config/modelProviders/huggingface.ts | 2 - src/config/modelProviders/hunyuan.ts | 2 - src/config/modelProviders/moonshot.ts | 2 + src/config/modelProviders/sensenova.ts | 2 - src/config/modelProviders/siliconcloud.ts | 2 - src/config/modelProviders/spark.ts | 2 - src/config/modelProviders/taichu.ts | 25 +++--- src/config/modelProviders/upstage.ts | 4 +- src/config/modelProviders/zeroone.ts | 6 +- src/libs/agent-runtime/ai360/index.ts | 24 ++++++ src/libs/agent-runtime/deepseek/index.ts | 17 +++++ src/libs/agent-runtime/groq/index.ts | 29 +++++++ src/libs/agent-runtime/internlm/index.ts | 17 +++++ src/libs/agent-runtime/moonshot/index.ts | 17 +++++ src/libs/agent-runtime/qwen/index.ts | 25 ++++++ src/libs/agent-runtime/stepfun/index.ts | 18 +++++ src/libs/agent-runtime/xai/index.ts | 18 +++++ src/libs/agent-runtime/zeroone/index.ts | 17 +++++ 24 files changed, 285 insertions(+), 91 deletions(-) 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 0aef41f19ceb..e59a401cff8e 100644 --- a/src/config/modelProviders/anthropic.ts +++ b/src/config/modelProviders/anthropic.ts @@ -142,7 +142,6 @@ const Anthropic: ModelProviderCard = { placeholder: 'https://api.anthropic.com', }, sdkType: 'anthropic', - showModelFetcher: true, smoothing: { speed: 5, text: true, diff --git a/src/config/modelProviders/baichuan.ts b/src/config/modelProviders/baichuan.ts index ce218da96c20..abd9055b3356 100644 --- a/src/config/modelProviders/baichuan.ts +++ b/src/config/modelProviders/baichuan.ts @@ -93,12 +93,10 @@ const Baichuan: ModelProviderCard = { description: '百川智能是一家专注于人工智能大模型研发的公司,其模型在国内知识百科、长文本处理和生成创作等中文任务上表现卓越,超越了国外主流模型。百川智能还具备行业领先的多模态能力,在多项权威评测中表现优异。其模型包括 Baichuan 4、Baichuan 3 Turbo 和 Baichuan 3 Turbo 128k 等,分别针对不同应用场景进行优化,提供高性价比的解决方案。', id: 'baichuan', - modelList: { showModelFetcher: true }, modelsUrl: 'https://platform.baichuan-ai.com/price', name: 'Baichuan', settings: { sdkType: 'openai', - showModelFetcher: true, smoothing: { speed: 2, text: true, diff --git a/src/config/modelProviders/fireworksai.ts b/src/config/modelProviders/fireworksai.ts index 615efb69c41a..41bb6e30ab14 100644 --- a/src/config/modelProviders/fireworksai.ts +++ b/src/config/modelProviders/fireworksai.ts @@ -215,12 +215,10 @@ const FireworksAI: ModelProviderCard = { description: 'Fireworks AI 是一家领先的高级语言模型服务商,专注于功能调用和多模态处理。其最新模型 Firefunction V2 基于 Llama-3,优化用于函数调用、对话及指令跟随。视觉语言模型 FireLLaVA-13B 支持图像和文本混合输入。其他 notable 模型包括 Llama 系列和 Mixtral 系列,提供高效的多语言指令跟随与生成支持。', id: 'fireworksai', - modelList: { showModelFetcher: true }, modelsUrl: 'https://fireworks.ai/models?show=Serverless', name: 'Fireworks AI', settings: { sdkType: 'openai', - showModelFetcher: true, }, url: 'https://fireworks.ai', }; diff --git a/src/config/modelProviders/giteeai.ts b/src/config/modelProviders/giteeai.ts index dde54eedc4c0..224287c4c301 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', @@ -115,13 +141,11 @@ const GiteeAI: ModelProviderCard = { description: 'Gitee AI 的 Serverless API 为 AI 开发者提供开箱即用的大模型推理 API 服务。', disableBrowserRequest: true, id: 'giteeai', - modelList: { showModelFetcher: true }, modelsUrl: 'https://ai.gitee.com/docs/openapi/v1#tag/serverless/POST/chat/completions', name: 'Gitee AI', settings: { disableBrowserRequest: true, sdkType: 'openai', - showModelFetcher: true, }, url: 'https://ai.gitee.com', }; diff --git a/src/config/modelProviders/huggingface.ts b/src/config/modelProviders/huggingface.ts index ace8370720c0..cba039ac7414 100644 --- a/src/config/modelProviders/huggingface.ts +++ b/src/config/modelProviders/huggingface.ts @@ -49,13 +49,11 @@ const HuggingFace: ModelProviderCard = { 'HuggingFace Inference API 提供了一种快速且免费的方式,让您可以探索成千上万种模型,适用于各种任务。无论您是在为新应用程序进行原型设计,还是在尝试机器学习的功能,这个 API 都能让您即时访问多个领域的高性能模型。', disableBrowserRequest: true, id: 'huggingface', - modelList: { showModelFetcher: true }, modelsUrl: 'https://huggingface.co/docs/api-inference/en/supported-models', name: 'HuggingFace', settings: { disableBrowserRequest: true, sdkType: 'huggingface', - showModelFetcher: true, }, url: 'https://huggingface.co', }; 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/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/sensenova.ts b/src/config/modelProviders/sensenova.ts index c755262ce9d1..d0cfc610f5a9 100644 --- a/src/config/modelProviders/sensenova.ts +++ b/src/config/modelProviders/sensenova.ts @@ -121,13 +121,11 @@ const SenseNova: ModelProviderCard = { description: '商汤日日新,依托商汤大装置的强大的基础支撑,提供高效易用的全栈大模型服务。', disableBrowserRequest: true, id: 'sensenova', - modelList: { showModelFetcher: true }, modelsUrl: 'https://platform.sensenova.cn/pricing', name: 'SenseNova', settings: { disableBrowserRequest: true, sdkType: 'openai', - showModelFetcher: true, }, url: 'https://platform.sensenova.cn/home', }; diff --git a/src/config/modelProviders/siliconcloud.ts b/src/config/modelProviders/siliconcloud.ts index 3116a7359d94..9de8fda0a476 100644 --- a/src/config/modelProviders/siliconcloud.ts +++ b/src/config/modelProviders/siliconcloud.ts @@ -592,7 +592,6 @@ const SiliconCloud: ModelProviderCard = { checkModel: 'Qwen/Qwen2.5-7B-Instruct', description: 'SiliconCloud,基于优秀开源基础模型的高性价比 GenAI 云服务', id: 'siliconcloud', - modelList: { showModelFetcher: true }, modelsUrl: 'https://siliconflow.cn/zh-cn/models', name: 'SiliconCloud', proxyUrl: { @@ -603,7 +602,6 @@ const SiliconCloud: ModelProviderCard = { placeholder: 'https://api.siliconflow.cn/v1', }, sdkType: 'openai', - showModelFetcher: true, }, url: 'https://siliconflow.cn/zh-cn/siliconcloud', }; 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/libs/agent-runtime/ai360/index.ts b/src/libs/agent-runtime/ai360/index.ts index 175ad951040a..8cc18c87055d 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/modelProviders'; + +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/deepseek/index.ts b/src/libs/agent-runtime/deepseek/index.ts index 9f312cbd28fd..5c29b0a8cf4b 100644 --- a/src/libs/agent-runtime/deepseek/index.ts +++ b/src/libs/agent-runtime/deepseek/index.ts @@ -1,10 +1,27 @@ import { ModelProvider } from '../types'; import { LobeOpenAICompatibleFactory } from '../utils/openaiCompatibleFactory'; +import { LOBE_DEFAULT_MODEL_LIST } from '@/config/modelProviders'; + +export interface DeepSeekModelCard { + id: string; +} + export const LobeDeepSeekAI = LobeOpenAICompatibleFactory({ baseURL: 'https://api.deepseek.com/v1', 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/groq/index.ts b/src/libs/agent-runtime/groq/index.ts index de6700fe7a8a..d890a8f4105e 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/modelProviders'; + +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.includes(keyword)), + id: model.id, + vision: model.id.includes('vision'), + }; + }, + }, provider: ModelProvider.Groq, }); diff --git a/src/libs/agent-runtime/internlm/index.ts b/src/libs/agent-runtime/internlm/index.ts index 3dfaf0edda41..7610da9e3c2d 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/modelProviders'; + +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/moonshot/index.ts b/src/libs/agent-runtime/moonshot/index.ts index 28c976d9dcf5..9e024190762a 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/modelProviders'; + +export interface MoonshotModelCard { + id: string; +} + export const LobeMoonshotAI = LobeOpenAICompatibleFactory({ baseURL: 'https://api.moonshot.cn/v1', chatCompletion: { @@ -18,5 +24,16 @@ 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, + }; + }, + }, provider: ModelProvider.Moonshot, }); diff --git a/src/libs/agent-runtime/qwen/index.ts b/src/libs/agent-runtime/qwen/index.ts index b0cc566f5b0b..86ab4e2e24ff 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/modelProviders'; + +export interface QwenModelCard { + id: string; +} + /* QwenLegacyModels: A set of legacy Qwen models that do not support presence_penalty. Currently, presence_penalty is only supported on Qwen commercial models and open-source models starting from Qwen 1.5 and later. @@ -45,6 +51,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.includes(keyword)), + id: model.id, + vision: model.id.includes('vl'), + }; + }, }, provider: ModelProvider.Qwen, }); diff --git a/src/libs/agent-runtime/stepfun/index.ts b/src/libs/agent-runtime/stepfun/index.ts index 4ae98b6fe3c7..52114c5e3a7f 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/modelProviders'; + +export interface StepfunModelCard { + id: string; +} + export const LobeStepfunAI = LobeOpenAICompatibleFactory({ baseURL: 'https://api.stepfun.com/v1', chatCompletion: { @@ -14,5 +20,17 @@ export const LobeStepfunAI = LobeOpenAICompatibleFactory({ debug: { chatCompletion: () => process.env.DEBUG_STEPFUN_CHAT_COMPLETION === '1', }, + models: { + transformModel: (m) => { + const model = m as unknown as StepfunModelCard; + + return { + enabled: LOBE_DEFAULT_MODEL_LIST.find((m) => model.id.endsWith(m.id))?.enabled || false, + functionCall: model.id !== 'step-1.5v-mini', + id: model.id, + vision: model.id.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..8d69170c53e0 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/modelProviders'; + +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.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..a9f1e563b02d 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/modelProviders'; + +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.includes('fc'), + id: model.id, + vision: model.id.includes('vision'), + }; + }, + }, provider: ModelProvider.ZeroOne, }); From ec83218adb860858fb97fa4c88f985b585f54433 Mon Sep 17 00:00:00 2001 From: Zhijie He Date: Tue, 7 Jan 2025 12:56:09 +0800 Subject: [PATCH 02/21] =?UTF-8?q?=F0=9F=92=84=20style:=20add=20Mistral=20M?= =?UTF-8?q?odelFetcher=20support?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/config/modelProviders/mistral.ts | 2 ++ src/libs/agent-runtime/mistral/index.ts | 26 +++++++++++++++++++++++++ 2 files changed, 28 insertions(+) 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/libs/agent-runtime/mistral/index.ts b/src/libs/agent-runtime/mistral/index.ts index 73fb9d0461c1..723206e70e65 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/modelProviders'; + +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, }); From b7e67c82cb6c34cec1a049ea2818f0d4ebded949 Mon Sep 17 00:00:00 2001 From: Zhijie He Date: Tue, 7 Jan 2025 20:49:05 +0800 Subject: [PATCH 03/21] =?UTF-8?q?=F0=9F=92=84=20style:=20add=20`glm-zero-p?= =?UTF-8?q?review`=20model=20for=20Zhipu?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/config/modelProviders/zhipu.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/config/modelProviders/zhipu.ts b/src/config/modelProviders/zhipu.ts index 3af7b39b8d56..ba0c5733154f 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 是处理简单任务的理想选择,速度最快且免费。', From e056ce7355112ed20c818de96ad3ff727590cbe4 Mon Sep 17 00:00:00 2001 From: Zhijie He Date: Tue, 7 Jan 2025 22:20:14 +0800 Subject: [PATCH 04/21] =?UTF-8?q?=F0=9F=92=84=20style:=20add=20more=20supp?= =?UTF-8?q?orted=20providers?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/config/modelProviders/fireworksai.ts | 2 ++ src/config/modelProviders/giteeai.ts | 2 ++ src/config/modelProviders/siliconcloud.ts | 2 ++ src/libs/agent-runtime/fireworksai/index.ts | 22 +++++++++++++ src/libs/agent-runtime/giteeai/index.ts | 28 ++++++++++++++++ src/libs/agent-runtime/siliconcloud/index.ts | 34 ++++++++++++++++++++ 6 files changed, 90 insertions(+) diff --git a/src/config/modelProviders/fireworksai.ts b/src/config/modelProviders/fireworksai.ts index 41bb6e30ab14..615efb69c41a 100644 --- a/src/config/modelProviders/fireworksai.ts +++ b/src/config/modelProviders/fireworksai.ts @@ -215,10 +215,12 @@ const FireworksAI: ModelProviderCard = { description: 'Fireworks AI 是一家领先的高级语言模型服务商,专注于功能调用和多模态处理。其最新模型 Firefunction V2 基于 Llama-3,优化用于函数调用、对话及指令跟随。视觉语言模型 FireLLaVA-13B 支持图像和文本混合输入。其他 notable 模型包括 Llama 系列和 Mixtral 系列,提供高效的多语言指令跟随与生成支持。', id: 'fireworksai', + modelList: { showModelFetcher: true }, modelsUrl: 'https://fireworks.ai/models?show=Serverless', name: 'Fireworks AI', settings: { sdkType: 'openai', + showModelFetcher: true, }, url: 'https://fireworks.ai', }; diff --git a/src/config/modelProviders/giteeai.ts b/src/config/modelProviders/giteeai.ts index 224287c4c301..641eb71fa973 100644 --- a/src/config/modelProviders/giteeai.ts +++ b/src/config/modelProviders/giteeai.ts @@ -141,11 +141,13 @@ const GiteeAI: ModelProviderCard = { description: 'Gitee AI 的 Serverless API 为 AI 开发者提供开箱即用的大模型推理 API 服务。', disableBrowserRequest: true, id: 'giteeai', + modelList: { showModelFetcher: true }, modelsUrl: 'https://ai.gitee.com/docs/openapi/v1#tag/serverless/POST/chat/completions', name: 'Gitee AI', settings: { disableBrowserRequest: true, sdkType: 'openai', + showModelFetcher: true, }, url: 'https://ai.gitee.com', }; diff --git a/src/config/modelProviders/siliconcloud.ts b/src/config/modelProviders/siliconcloud.ts index 9de8fda0a476..3116a7359d94 100644 --- a/src/config/modelProviders/siliconcloud.ts +++ b/src/config/modelProviders/siliconcloud.ts @@ -592,6 +592,7 @@ const SiliconCloud: ModelProviderCard = { checkModel: 'Qwen/Qwen2.5-7B-Instruct', description: 'SiliconCloud,基于优秀开源基础模型的高性价比 GenAI 云服务', id: 'siliconcloud', + modelList: { showModelFetcher: true }, modelsUrl: 'https://siliconflow.cn/zh-cn/models', name: 'SiliconCloud', proxyUrl: { @@ -602,6 +603,7 @@ const SiliconCloud: ModelProviderCard = { placeholder: 'https://api.siliconflow.cn/v1', }, sdkType: 'openai', + showModelFetcher: true, }, url: 'https://siliconflow.cn/zh-cn/siliconcloud', }; diff --git a/src/libs/agent-runtime/fireworksai/index.ts b/src/libs/agent-runtime/fireworksai/index.ts index 3f3fe872d8fb..19879b68eef7 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/modelProviders'; + +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, + 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..04d688a8d056 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/modelProviders'; + +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.includes(keyword)) && !model.id.includes('Qwen2.5-Coder'), + id: model.id, + vision: visionKeywords.some(keyword => model.id.includes(keyword)), + }; + }, + }, provider: ModelProvider.GiteeAI, }); diff --git a/src/libs/agent-runtime/siliconcloud/index.ts b/src/libs/agent-runtime/siliconcloud/index.ts index edc28f455e0f..e4292f41ba7c 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/modelProviders'; + +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.includes(keyword)), + id: model.id, + vision: visionKeywords.some(keyword => model.id.includes(keyword)), + }; + }, + }, provider: ModelProvider.SiliconCloud, }); From 4757282247f41ba49c9211461c421eaf495194f5 Mon Sep 17 00:00:00 2001 From: Zhijie He Date: Tue, 7 Jan 2025 23:39:59 +0800 Subject: [PATCH 05/21] =?UTF-8?q?=F0=9F=92=84=20style:=20add=20SenseNova?= =?UTF-8?q?=20&=20Baichuan=20support=20with=20custom=20models=20endpoint?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/config/modelProviders/baichuan.ts | 2 ++ src/config/modelProviders/sensenova.ts | 2 ++ src/libs/agent-runtime/baichuan/index.ts | 28 ++++++++++++++++++++ src/libs/agent-runtime/giteeai/index.ts | 10 +++---- src/libs/agent-runtime/groq/index.ts | 4 +-- src/libs/agent-runtime/qwen/index.ts | 4 +-- src/libs/agent-runtime/sensenova/index.ts | 28 ++++++++++++++++++++ src/libs/agent-runtime/siliconcloud/index.ts | 20 +++++++------- src/libs/agent-runtime/stepfun/index.ts | 2 +- src/libs/agent-runtime/xai/index.ts | 2 +- src/libs/agent-runtime/zeroone/index.ts | 4 +-- 11 files changed, 83 insertions(+), 23 deletions(-) diff --git a/src/config/modelProviders/baichuan.ts b/src/config/modelProviders/baichuan.ts index abd9055b3356..ce218da96c20 100644 --- a/src/config/modelProviders/baichuan.ts +++ b/src/config/modelProviders/baichuan.ts @@ -93,10 +93,12 @@ const Baichuan: ModelProviderCard = { description: '百川智能是一家专注于人工智能大模型研发的公司,其模型在国内知识百科、长文本处理和生成创作等中文任务上表现卓越,超越了国外主流模型。百川智能还具备行业领先的多模态能力,在多项权威评测中表现优异。其模型包括 Baichuan 4、Baichuan 3 Turbo 和 Baichuan 3 Turbo 128k 等,分别针对不同应用场景进行优化,提供高性价比的解决方案。', id: 'baichuan', + modelList: { showModelFetcher: true }, modelsUrl: 'https://platform.baichuan-ai.com/price', name: 'Baichuan', settings: { sdkType: 'openai', + showModelFetcher: true, smoothing: { speed: 2, text: true, diff --git a/src/config/modelProviders/sensenova.ts b/src/config/modelProviders/sensenova.ts index d0cfc610f5a9..c755262ce9d1 100644 --- a/src/config/modelProviders/sensenova.ts +++ b/src/config/modelProviders/sensenova.ts @@ -121,11 +121,13 @@ const SenseNova: ModelProviderCard = { description: '商汤日日新,依托商汤大装置的强大的基础支撑,提供高效易用的全栈大模型服务。', disableBrowserRequest: true, id: 'sensenova', + modelList: { showModelFetcher: true }, modelsUrl: 'https://platform.sensenova.cn/pricing', name: 'SenseNova', settings: { disableBrowserRequest: true, sdkType: 'openai', + showModelFetcher: true, }, url: 'https://platform.sensenova.cn/home', }; diff --git a/src/libs/agent-runtime/baichuan/index.ts b/src/libs/agent-runtime/baichuan/index.ts index 3178977af4ac..649308edb7af 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/modelProviders'; +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/giteeai/index.ts b/src/libs/agent-runtime/giteeai/index.ts index 04d688a8d056..e8749a12b3c0 100644 --- a/src/libs/agent-runtime/giteeai/index.ts +++ b/src/libs/agent-runtime/giteeai/index.ts @@ -15,22 +15,22 @@ export const LobeGiteeAI = LobeOpenAICompatibleFactory({ models: { transformModel: (m) => { const functionCallKeywords = [ - 'Qwen2.5', + 'qwen2.5', 'glm-4', ]; const visionKeywords = [ - 'InternVL', - 'Qwen2-VL', + '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.includes(keyword)) && !model.id.includes('Qwen2.5-Coder'), + 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.includes(keyword)), + vision: visionKeywords.some(keyword => model.id.toLowerCase().includes(keyword)), }; }, }, diff --git a/src/libs/agent-runtime/groq/index.ts b/src/libs/agent-runtime/groq/index.ts index d890a8f4105e..271014f12f9b 100644 --- a/src/libs/agent-runtime/groq/index.ts +++ b/src/libs/agent-runtime/groq/index.ts @@ -47,9 +47,9 @@ export const LobeGroq = LobeOpenAICompatibleFactory({ 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.includes(keyword)), + functionCall: functionCallKeywords.some(keyword => model.id.toLowerCase().includes(keyword)), id: model.id, - vision: model.id.includes('vision'), + vision: model.id.toLowerCase().includes('vision'), }; }, }, diff --git a/src/libs/agent-runtime/qwen/index.ts b/src/libs/agent-runtime/qwen/index.ts index 86ab4e2e24ff..0dbcac08168c 100644 --- a/src/libs/agent-runtime/qwen/index.ts +++ b/src/libs/agent-runtime/qwen/index.ts @@ -65,9 +65,9 @@ export const LobeQwenAI = LobeOpenAICompatibleFactory({ return { enabled: LOBE_DEFAULT_MODEL_LIST.find((m) => model.id.endsWith(m.id))?.enabled || false, - functionCall: functionCallKeywords.some(keyword => model.id.includes(keyword)), + functionCall: functionCallKeywords.some(keyword => model.id.toLowerCase().includes(keyword)), id: model.id, - vision: model.id.includes('vl'), + vision: model.id.toLowerCase().includes('vl'), }; }, }, diff --git a/src/libs/agent-runtime/sensenova/index.ts b/src/libs/agent-runtime/sensenova/index.ts index f551847a693c..8afe93f5f934 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/modelProviders'; +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 e4292f41ba7c..f3b6495f1f87 100644 --- a/src/libs/agent-runtime/siliconcloud/index.ts +++ b/src/libs/agent-runtime/siliconcloud/index.ts @@ -23,18 +23,18 @@ export const LobeSiliconCloudAI = LobeOpenAICompatibleFactory({ models: { transformModel: (m) => { const functionCallKeywords = [ - 'Qwen/Qwen2.5', - 'THUDM/glm-4', - 'deepseek-ai/DeepSeek', + 'qwen/qwen2.5', + 'thudm/glm-4', + 'deepseek-ai/deepSeek', 'internlm/internlm2_5', - 'meta-llama/Meta-Llama-3.1', - 'meta-llama/Meta-Llama-3.3', + 'meta-llama/meta-llama-3.1', + 'meta-llama/meta-llama-3.3', ]; const visionKeywords = [ - 'OpenGVLab/InternVL', - 'Qwen/Qwen2-VL', - 'TeleAI/TeleMM', + 'opengvlab/internvl', + 'qwen/qwen2-vl', + 'teleai/telemm', 'deepseek-ai/deepseek-vl', ]; @@ -42,9 +42,9 @@ export const LobeSiliconCloudAI = LobeOpenAICompatibleFactory({ return { enabled: LOBE_DEFAULT_MODEL_LIST.find((m) => model.id.endsWith(m.id))?.enabled || false, - functionCall: functionCallKeywords.some(keyword => model.id.includes(keyword)), + functionCall: functionCallKeywords.some(keyword => model.id.toLowerCase().includes(keyword)), id: model.id, - vision: visionKeywords.some(keyword => model.id.includes(keyword)), + vision: visionKeywords.some(keyword => model.id.toLowerCase().includes(keyword)), }; }, }, diff --git a/src/libs/agent-runtime/stepfun/index.ts b/src/libs/agent-runtime/stepfun/index.ts index 52114c5e3a7f..617ef9aa0429 100644 --- a/src/libs/agent-runtime/stepfun/index.ts +++ b/src/libs/agent-runtime/stepfun/index.ts @@ -28,7 +28,7 @@ export const LobeStepfunAI = LobeOpenAICompatibleFactory({ enabled: LOBE_DEFAULT_MODEL_LIST.find((m) => model.id.endsWith(m.id))?.enabled || false, functionCall: model.id !== 'step-1.5v-mini', id: model.id, - vision: model.id.includes('v'), + vision: model.id.toLowerCase().includes('v'), }; }, }, diff --git a/src/libs/agent-runtime/xai/index.ts b/src/libs/agent-runtime/xai/index.ts index 8d69170c53e0..fe896a5eba97 100644 --- a/src/libs/agent-runtime/xai/index.ts +++ b/src/libs/agent-runtime/xai/index.ts @@ -20,7 +20,7 @@ export const LobeXAI = LobeOpenAICompatibleFactory({ enabled: LOBE_DEFAULT_MODEL_LIST.find((m) => model.id.endsWith(m.id))?.enabled || false, functionCall: true, id: model.id, - vision: model.id.includes('vision'), + vision: model.id.toLowerCase().includes('vision'), }; }, }, diff --git a/src/libs/agent-runtime/zeroone/index.ts b/src/libs/agent-runtime/zeroone/index.ts index a9f1e563b02d..50f1cd48eed4 100644 --- a/src/libs/agent-runtime/zeroone/index.ts +++ b/src/libs/agent-runtime/zeroone/index.ts @@ -18,9 +18,9 @@ export const LobeZeroOneAI = LobeOpenAICompatibleFactory({ return { enabled: LOBE_DEFAULT_MODEL_LIST.find((m) => model.id.endsWith(m.id))?.enabled || false, - functionCall: model.id.includes('fc'), + functionCall: model.id.toLowerCase().includes('fc'), id: model.id, - vision: model.id.includes('vision'), + vision: model.id.toLowerCase().includes('vision'), }; }, }, From 18e03957f36eefce907c25697613bfc4ff1c2a4e Mon Sep 17 00:00:00 2001 From: Zhijie He Date: Tue, 7 Jan 2025 23:47:34 +0800 Subject: [PATCH 06/21] =?UTF-8?q?=F0=9F=90=9B=20fix:=20fix=20fc=20keyword?= =?UTF-8?q?=20typo,=20should=20lowercase?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/libs/agent-runtime/sensenova/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/agent-runtime/sensenova/index.ts b/src/libs/agent-runtime/sensenova/index.ts index 8afe93f5f934..ae7d174c6d21 100644 --- a/src/libs/agent-runtime/sensenova/index.ts +++ b/src/libs/agent-runtime/sensenova/index.ts @@ -34,7 +34,7 @@ export const LobeSenseNovaAI = LobeOpenAICompatibleFactory({ }, models: async ({ client }) => { const functionCallKeywords = [ - 'SenseChat-5', + 'sensechat-5', ]; client.baseURL = 'https://api.sensenova.cn/v1/llm'; From 7fb95a015da05ca7daba50292d7e7ce33decbad4 Mon Sep 17 00:00:00 2001 From: Zhijie He Date: Wed, 8 Jan 2025 01:32:48 +0800 Subject: [PATCH 07/21] =?UTF-8?q?=F0=9F=92=84=20style:=20update=20aiModels?= =?UTF-8?q?=20list?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/config/aiModels/ai360.ts | 50 +++++++++--------- src/config/aiModels/giteeai.ts | 92 ++++++++++++++++++++++------------ src/config/aiModels/taichu.ts | 23 ++++++++- src/config/aiModels/upstage.ts | 2 +- src/config/aiModels/zhipu.ts | 13 +++++ 5 files changed, 120 insertions(+), 60 deletions(-) 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/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, From 049662da228c4303f2b1f6929aa7a4756487b2a0 Mon Sep 17 00:00:00 2001 From: Zhijie He Date: Wed, 8 Jan 2025 01:48:31 +0800 Subject: [PATCH 08/21] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20refactor:=20use=20ai?= =?UTF-8?q?Models=20sheme?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/libs/agent-runtime/ai360/index.ts | 4 +++- src/libs/agent-runtime/baichuan/index.ts | 4 +++- src/libs/agent-runtime/deepseek/index.ts | 4 +++- src/libs/agent-runtime/fireworksai/index.ts | 6 ++++-- src/libs/agent-runtime/giteeai/index.ts | 6 ++++-- src/libs/agent-runtime/groq/index.ts | 6 ++++-- src/libs/agent-runtime/internlm/index.ts | 4 +++- src/libs/agent-runtime/mistral/index.ts | 6 ++++-- src/libs/agent-runtime/moonshot/index.ts | 4 +++- src/libs/agent-runtime/qwen/index.ts | 6 ++++-- src/libs/agent-runtime/sensenova/index.ts | 6 ++++-- src/libs/agent-runtime/siliconcloud/index.ts | 6 ++++-- src/libs/agent-runtime/stepfun/index.ts | 6 ++++-- src/libs/agent-runtime/xai/index.ts | 6 ++++-- src/libs/agent-runtime/zeroone/index.ts | 6 ++++-- 15 files changed, 55 insertions(+), 25 deletions(-) diff --git a/src/libs/agent-runtime/ai360/index.ts b/src/libs/agent-runtime/ai360/index.ts index 8cc18c87055d..481b1c93dcdb 100644 --- a/src/libs/agent-runtime/ai360/index.ts +++ b/src/libs/agent-runtime/ai360/index.ts @@ -27,9 +27,11 @@ export const LobeAi360AI = LobeOpenAICompatibleFactory({ const model = m as unknown as Ai360ModelCard; return { + abilities: { + functionCall: model.id === '360gpt-pro', + }, 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' diff --git a/src/libs/agent-runtime/baichuan/index.ts b/src/libs/agent-runtime/baichuan/index.ts index 649308edb7af..f5f5289a2370 100644 --- a/src/libs/agent-runtime/baichuan/index.ts +++ b/src/libs/agent-runtime/baichuan/index.ts @@ -38,10 +38,12 @@ export const LobeBaichuanAI = LobeOpenAICompatibleFactory({ return modelList .map((model) => { return { + abilities: { + functionCall: model.function_call, + }, 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, }; diff --git a/src/libs/agent-runtime/deepseek/index.ts b/src/libs/agent-runtime/deepseek/index.ts index 5c29b0a8cf4b..f1cc31ebd3f0 100644 --- a/src/libs/agent-runtime/deepseek/index.ts +++ b/src/libs/agent-runtime/deepseek/index.ts @@ -17,8 +17,10 @@ export const LobeDeepSeekAI = LobeOpenAICompatibleFactory({ const model = m as unknown as DeepSeekModelCard; return { + abilities: { + functionCall: true, + }, enabled: LOBE_DEFAULT_MODEL_LIST.find((m) => model.id.endsWith(m.id))?.enabled || false, - functionCall: true, id: model.id, }; }, diff --git a/src/libs/agent-runtime/fireworksai/index.ts b/src/libs/agent-runtime/fireworksai/index.ts index 19879b68eef7..5f9f623fad0d 100644 --- a/src/libs/agent-runtime/fireworksai/index.ts +++ b/src/libs/agent-runtime/fireworksai/index.ts @@ -20,11 +20,13 @@ export const LobeFireworksAI = LobeOpenAICompatibleFactory({ const model = m as unknown as FireworksAIModelCard; return { + abilities: { + functionCall: model.supports_tools, + vision: model.supports_image_input, + }, contextWindowTokens: model.context_length, enabled: LOBE_DEFAULT_MODEL_LIST.find((m) => model.id.endsWith(m.id))?.enabled || false, - functionCall: model.supports_tools, id: model.id, - vision: model.supports_image_input, }; }, }, diff --git a/src/libs/agent-runtime/giteeai/index.ts b/src/libs/agent-runtime/giteeai/index.ts index e8749a12b3c0..42cccbe6a0eb 100644 --- a/src/libs/agent-runtime/giteeai/index.ts +++ b/src/libs/agent-runtime/giteeai/index.ts @@ -27,10 +27,12 @@ export const LobeGiteeAI = LobeOpenAICompatibleFactory({ const model = m as unknown as GiteeAIModelCard; return { + abilities: { + functionCall: functionCallKeywords.some(keyword => model.id.toLowerCase().includes(keyword)) && !model.id.toLowerCase().includes('qwen2.5-coder'), + vision: visionKeywords.some(keyword => model.id.toLowerCase().includes(keyword)), + }, 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)), }; }, }, diff --git a/src/libs/agent-runtime/groq/index.ts b/src/libs/agent-runtime/groq/index.ts index 271014f12f9b..1460cbb6573f 100644 --- a/src/libs/agent-runtime/groq/index.ts +++ b/src/libs/agent-runtime/groq/index.ts @@ -45,11 +45,13 @@ export const LobeGroq = LobeOpenAICompatibleFactory({ const model = m as unknown as GroqModelCard; return { + abilities: { + functionCall: functionCallKeywords.some(keyword => model.id.toLowerCase().includes(keyword)), + vision: model.id.toLowerCase().includes('vision'), + }, 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'), }; }, }, diff --git a/src/libs/agent-runtime/internlm/index.ts b/src/libs/agent-runtime/internlm/index.ts index 7610da9e3c2d..6b62e5fc5974 100644 --- a/src/libs/agent-runtime/internlm/index.ts +++ b/src/libs/agent-runtime/internlm/index.ts @@ -25,8 +25,10 @@ export const LobeInternLMAI = LobeOpenAICompatibleFactory({ const model = m as unknown as InternLMModelCard; return { + abilities: { + functionCall: true, + }, enabled: LOBE_DEFAULT_MODEL_LIST.find((m) => model.id.endsWith(m.id))?.enabled || false, - functionCall: true, id: model.id, }; }, diff --git a/src/libs/agent-runtime/mistral/index.ts b/src/libs/agent-runtime/mistral/index.ts index 723206e70e65..634df0ec1aae 100644 --- a/src/libs/agent-runtime/mistral/index.ts +++ b/src/libs/agent-runtime/mistral/index.ts @@ -35,12 +35,14 @@ export const LobeMistralAI = LobeOpenAICompatibleFactory({ const model = m as unknown as MistralModelCard; return { + abilities: { + functionCall: model.capabilities.function_calling, + vision: model.capabilities.vision, + }, 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, }; }, }, diff --git a/src/libs/agent-runtime/moonshot/index.ts b/src/libs/agent-runtime/moonshot/index.ts index 9e024190762a..7ec6eb264d1f 100644 --- a/src/libs/agent-runtime/moonshot/index.ts +++ b/src/libs/agent-runtime/moonshot/index.ts @@ -29,8 +29,10 @@ export const LobeMoonshotAI = LobeOpenAICompatibleFactory({ const model = m as unknown as MoonshotModelCard; return { + abilities: { + functionCall: true, + }, enabled: LOBE_DEFAULT_MODEL_LIST.find((m) => model.id.endsWith(m.id))?.enabled || false, - functionCall: true, id: model.id, }; }, diff --git a/src/libs/agent-runtime/qwen/index.ts b/src/libs/agent-runtime/qwen/index.ts index 0dbcac08168c..f1cb608dcb47 100644 --- a/src/libs/agent-runtime/qwen/index.ts +++ b/src/libs/agent-runtime/qwen/index.ts @@ -64,10 +64,12 @@ export const LobeQwenAI = LobeOpenAICompatibleFactory({ const model = m as unknown as QwenModelCard; return { + abilities: { + functionCall: functionCallKeywords.some(keyword => model.id.toLowerCase().includes(keyword)), + vision: model.id.toLowerCase().includes('vl'), + }, 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'), }; }, }, diff --git a/src/libs/agent-runtime/sensenova/index.ts b/src/libs/agent-runtime/sensenova/index.ts index ae7d174c6d21..684bb8869456 100644 --- a/src/libs/agent-runtime/sensenova/index.ts +++ b/src/libs/agent-runtime/sensenova/index.ts @@ -45,10 +45,12 @@ export const LobeSenseNovaAI = LobeOpenAICompatibleFactory({ return modelList .map((model) => { return { + abilities: { + functionCall: functionCallKeywords.some(keyword => model.id.toLowerCase().includes(keyword)), + vision: model.id.toLowerCase().includes('vision'), + }, 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[]; diff --git a/src/libs/agent-runtime/siliconcloud/index.ts b/src/libs/agent-runtime/siliconcloud/index.ts index f3b6495f1f87..566d4d660d07 100644 --- a/src/libs/agent-runtime/siliconcloud/index.ts +++ b/src/libs/agent-runtime/siliconcloud/index.ts @@ -41,10 +41,12 @@ export const LobeSiliconCloudAI = LobeOpenAICompatibleFactory({ const model = m as unknown as SiliconCloudModelCard; return { + abilities: { + functionCall: functionCallKeywords.some(keyword => model.id.toLowerCase().includes(keyword)), + vision: visionKeywords.some(keyword => model.id.toLowerCase().includes(keyword)), + }, 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)), }; }, }, diff --git a/src/libs/agent-runtime/stepfun/index.ts b/src/libs/agent-runtime/stepfun/index.ts index 617ef9aa0429..31059af6f1f0 100644 --- a/src/libs/agent-runtime/stepfun/index.ts +++ b/src/libs/agent-runtime/stepfun/index.ts @@ -25,10 +25,12 @@ export const LobeStepfunAI = LobeOpenAICompatibleFactory({ const model = m as unknown as StepfunModelCard; return { + abilities: { + functionCall: model.id !== 'step-1.5v-mini', + vision: model.id.toLowerCase().includes('v'), + }, enabled: LOBE_DEFAULT_MODEL_LIST.find((m) => model.id.endsWith(m.id))?.enabled || false, - functionCall: model.id !== 'step-1.5v-mini', id: model.id, - vision: model.id.toLowerCase().includes('v'), }; }, }, diff --git a/src/libs/agent-runtime/xai/index.ts b/src/libs/agent-runtime/xai/index.ts index fe896a5eba97..4bbfa1fe5230 100644 --- a/src/libs/agent-runtime/xai/index.ts +++ b/src/libs/agent-runtime/xai/index.ts @@ -17,10 +17,12 @@ export const LobeXAI = LobeOpenAICompatibleFactory({ const model = m as unknown as XAIModelCard; return { + abilities: { + functionCall: true, + vision: model.id.toLowerCase().includes('vision'), + }, 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'), }; }, }, diff --git a/src/libs/agent-runtime/zeroone/index.ts b/src/libs/agent-runtime/zeroone/index.ts index 50f1cd48eed4..7a796e3626bd 100644 --- a/src/libs/agent-runtime/zeroone/index.ts +++ b/src/libs/agent-runtime/zeroone/index.ts @@ -17,10 +17,12 @@ export const LobeZeroOneAI = LobeOpenAICompatibleFactory({ const model = m as unknown as ZeroOneModelCard; return { + abilities: { + functionCall: model.id.toLowerCase().includes('fc'), + vision: model.id.toLowerCase().includes('vision'), + }, 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'), }; }, }, From f27b46b50050bfdacbac7b6bbfcc38b25cad0f83 Mon Sep 17 00:00:00 2001 From: Zhijie He Date: Wed, 8 Jan 2025 01:58:54 +0800 Subject: [PATCH 09/21] =?UTF-8?q?Revert=20"=E2=99=BB=EF=B8=8F=20refactor:?= =?UTF-8?q?=20use=20aiModels=20sheme"=20(#252)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 049662da228c4303f2b1f6929aa7a4756487b2a0. --- src/libs/agent-runtime/ai360/index.ts | 4 +--- src/libs/agent-runtime/baichuan/index.ts | 4 +--- src/libs/agent-runtime/deepseek/index.ts | 4 +--- src/libs/agent-runtime/fireworksai/index.ts | 6 ++---- src/libs/agent-runtime/giteeai/index.ts | 6 ++---- src/libs/agent-runtime/groq/index.ts | 6 ++---- src/libs/agent-runtime/internlm/index.ts | 4 +--- src/libs/agent-runtime/mistral/index.ts | 6 ++---- src/libs/agent-runtime/moonshot/index.ts | 4 +--- src/libs/agent-runtime/qwen/index.ts | 6 ++---- src/libs/agent-runtime/sensenova/index.ts | 6 ++---- src/libs/agent-runtime/siliconcloud/index.ts | 6 ++---- src/libs/agent-runtime/stepfun/index.ts | 6 ++---- src/libs/agent-runtime/xai/index.ts | 6 ++---- src/libs/agent-runtime/zeroone/index.ts | 6 ++---- 15 files changed, 25 insertions(+), 55 deletions(-) diff --git a/src/libs/agent-runtime/ai360/index.ts b/src/libs/agent-runtime/ai360/index.ts index 481b1c93dcdb..8cc18c87055d 100644 --- a/src/libs/agent-runtime/ai360/index.ts +++ b/src/libs/agent-runtime/ai360/index.ts @@ -27,11 +27,9 @@ export const LobeAi360AI = LobeOpenAICompatibleFactory({ const model = m as unknown as Ai360ModelCard; return { - abilities: { - functionCall: model.id === '360gpt-pro', - }, 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' diff --git a/src/libs/agent-runtime/baichuan/index.ts b/src/libs/agent-runtime/baichuan/index.ts index f5f5289a2370..649308edb7af 100644 --- a/src/libs/agent-runtime/baichuan/index.ts +++ b/src/libs/agent-runtime/baichuan/index.ts @@ -38,12 +38,10 @@ export const LobeBaichuanAI = LobeOpenAICompatibleFactory({ return modelList .map((model) => { return { - abilities: { - functionCall: model.function_call, - }, 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, }; diff --git a/src/libs/agent-runtime/deepseek/index.ts b/src/libs/agent-runtime/deepseek/index.ts index f1cc31ebd3f0..5c29b0a8cf4b 100644 --- a/src/libs/agent-runtime/deepseek/index.ts +++ b/src/libs/agent-runtime/deepseek/index.ts @@ -17,10 +17,8 @@ export const LobeDeepSeekAI = LobeOpenAICompatibleFactory({ const model = m as unknown as DeepSeekModelCard; return { - abilities: { - functionCall: true, - }, enabled: LOBE_DEFAULT_MODEL_LIST.find((m) => model.id.endsWith(m.id))?.enabled || false, + functionCall: true, id: model.id, }; }, diff --git a/src/libs/agent-runtime/fireworksai/index.ts b/src/libs/agent-runtime/fireworksai/index.ts index 5f9f623fad0d..19879b68eef7 100644 --- a/src/libs/agent-runtime/fireworksai/index.ts +++ b/src/libs/agent-runtime/fireworksai/index.ts @@ -20,13 +20,11 @@ export const LobeFireworksAI = LobeOpenAICompatibleFactory({ const model = m as unknown as FireworksAIModelCard; return { - abilities: { - functionCall: model.supports_tools, - vision: model.supports_image_input, - }, contextWindowTokens: model.context_length, enabled: LOBE_DEFAULT_MODEL_LIST.find((m) => model.id.endsWith(m.id))?.enabled || false, + functionCall: model.supports_tools, id: model.id, + vision: model.supports_image_input, }; }, }, diff --git a/src/libs/agent-runtime/giteeai/index.ts b/src/libs/agent-runtime/giteeai/index.ts index 42cccbe6a0eb..e8749a12b3c0 100644 --- a/src/libs/agent-runtime/giteeai/index.ts +++ b/src/libs/agent-runtime/giteeai/index.ts @@ -27,12 +27,10 @@ export const LobeGiteeAI = LobeOpenAICompatibleFactory({ const model = m as unknown as GiteeAIModelCard; return { - abilities: { - functionCall: functionCallKeywords.some(keyword => model.id.toLowerCase().includes(keyword)) && !model.id.toLowerCase().includes('qwen2.5-coder'), - vision: visionKeywords.some(keyword => model.id.toLowerCase().includes(keyword)), - }, 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)), }; }, }, diff --git a/src/libs/agent-runtime/groq/index.ts b/src/libs/agent-runtime/groq/index.ts index 1460cbb6573f..271014f12f9b 100644 --- a/src/libs/agent-runtime/groq/index.ts +++ b/src/libs/agent-runtime/groq/index.ts @@ -45,13 +45,11 @@ export const LobeGroq = LobeOpenAICompatibleFactory({ const model = m as unknown as GroqModelCard; return { - abilities: { - functionCall: functionCallKeywords.some(keyword => model.id.toLowerCase().includes(keyword)), - vision: model.id.toLowerCase().includes('vision'), - }, 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'), }; }, }, diff --git a/src/libs/agent-runtime/internlm/index.ts b/src/libs/agent-runtime/internlm/index.ts index 6b62e5fc5974..7610da9e3c2d 100644 --- a/src/libs/agent-runtime/internlm/index.ts +++ b/src/libs/agent-runtime/internlm/index.ts @@ -25,10 +25,8 @@ export const LobeInternLMAI = LobeOpenAICompatibleFactory({ const model = m as unknown as InternLMModelCard; return { - abilities: { - functionCall: true, - }, enabled: LOBE_DEFAULT_MODEL_LIST.find((m) => model.id.endsWith(m.id))?.enabled || false, + functionCall: true, id: model.id, }; }, diff --git a/src/libs/agent-runtime/mistral/index.ts b/src/libs/agent-runtime/mistral/index.ts index 634df0ec1aae..723206e70e65 100644 --- a/src/libs/agent-runtime/mistral/index.ts +++ b/src/libs/agent-runtime/mistral/index.ts @@ -35,14 +35,12 @@ export const LobeMistralAI = LobeOpenAICompatibleFactory({ const model = m as unknown as MistralModelCard; return { - abilities: { - functionCall: model.capabilities.function_calling, - vision: model.capabilities.vision, - }, 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, }; }, }, diff --git a/src/libs/agent-runtime/moonshot/index.ts b/src/libs/agent-runtime/moonshot/index.ts index 7ec6eb264d1f..9e024190762a 100644 --- a/src/libs/agent-runtime/moonshot/index.ts +++ b/src/libs/agent-runtime/moonshot/index.ts @@ -29,10 +29,8 @@ export const LobeMoonshotAI = LobeOpenAICompatibleFactory({ const model = m as unknown as MoonshotModelCard; return { - abilities: { - functionCall: true, - }, enabled: LOBE_DEFAULT_MODEL_LIST.find((m) => model.id.endsWith(m.id))?.enabled || false, + functionCall: true, id: model.id, }; }, diff --git a/src/libs/agent-runtime/qwen/index.ts b/src/libs/agent-runtime/qwen/index.ts index f1cb608dcb47..0dbcac08168c 100644 --- a/src/libs/agent-runtime/qwen/index.ts +++ b/src/libs/agent-runtime/qwen/index.ts @@ -64,12 +64,10 @@ export const LobeQwenAI = LobeOpenAICompatibleFactory({ const model = m as unknown as QwenModelCard; return { - abilities: { - functionCall: functionCallKeywords.some(keyword => model.id.toLowerCase().includes(keyword)), - vision: model.id.toLowerCase().includes('vl'), - }, 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'), }; }, }, diff --git a/src/libs/agent-runtime/sensenova/index.ts b/src/libs/agent-runtime/sensenova/index.ts index 684bb8869456..ae7d174c6d21 100644 --- a/src/libs/agent-runtime/sensenova/index.ts +++ b/src/libs/agent-runtime/sensenova/index.ts @@ -45,12 +45,10 @@ export const LobeSenseNovaAI = LobeOpenAICompatibleFactory({ return modelList .map((model) => { return { - abilities: { - functionCall: functionCallKeywords.some(keyword => model.id.toLowerCase().includes(keyword)), - vision: model.id.toLowerCase().includes('vision'), - }, 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[]; diff --git a/src/libs/agent-runtime/siliconcloud/index.ts b/src/libs/agent-runtime/siliconcloud/index.ts index 566d4d660d07..f3b6495f1f87 100644 --- a/src/libs/agent-runtime/siliconcloud/index.ts +++ b/src/libs/agent-runtime/siliconcloud/index.ts @@ -41,12 +41,10 @@ export const LobeSiliconCloudAI = LobeOpenAICompatibleFactory({ const model = m as unknown as SiliconCloudModelCard; return { - abilities: { - functionCall: functionCallKeywords.some(keyword => model.id.toLowerCase().includes(keyword)), - vision: visionKeywords.some(keyword => model.id.toLowerCase().includes(keyword)), - }, 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)), }; }, }, diff --git a/src/libs/agent-runtime/stepfun/index.ts b/src/libs/agent-runtime/stepfun/index.ts index 31059af6f1f0..617ef9aa0429 100644 --- a/src/libs/agent-runtime/stepfun/index.ts +++ b/src/libs/agent-runtime/stepfun/index.ts @@ -25,12 +25,10 @@ export const LobeStepfunAI = LobeOpenAICompatibleFactory({ const model = m as unknown as StepfunModelCard; return { - abilities: { - functionCall: model.id !== 'step-1.5v-mini', - vision: model.id.toLowerCase().includes('v'), - }, enabled: LOBE_DEFAULT_MODEL_LIST.find((m) => model.id.endsWith(m.id))?.enabled || false, + functionCall: model.id !== 'step-1.5v-mini', id: model.id, + vision: model.id.toLowerCase().includes('v'), }; }, }, diff --git a/src/libs/agent-runtime/xai/index.ts b/src/libs/agent-runtime/xai/index.ts index 4bbfa1fe5230..fe896a5eba97 100644 --- a/src/libs/agent-runtime/xai/index.ts +++ b/src/libs/agent-runtime/xai/index.ts @@ -17,12 +17,10 @@ export const LobeXAI = LobeOpenAICompatibleFactory({ const model = m as unknown as XAIModelCard; return { - abilities: { - functionCall: true, - vision: model.id.toLowerCase().includes('vision'), - }, 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'), }; }, }, diff --git a/src/libs/agent-runtime/zeroone/index.ts b/src/libs/agent-runtime/zeroone/index.ts index 7a796e3626bd..50f1cd48eed4 100644 --- a/src/libs/agent-runtime/zeroone/index.ts +++ b/src/libs/agent-runtime/zeroone/index.ts @@ -17,12 +17,10 @@ export const LobeZeroOneAI = LobeOpenAICompatibleFactory({ const model = m as unknown as ZeroOneModelCard; return { - abilities: { - functionCall: model.id.toLowerCase().includes('fc'), - vision: model.id.toLowerCase().includes('vision'), - }, 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'), }; }, }, From 7fb875dc6a7b4680e9d1c762fa35074426cd5856 Mon Sep 17 00:00:00 2001 From: Zhijie He Date: Wed, 8 Jan 2025 06:35:59 +0800 Subject: [PATCH 10/21] =?UTF-8?q?=F0=9F=90=9B=20fix:=20fix=20`firefunction?= =?UTF-8?q?`=20series=20not=20set=20as=20functionCall?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/libs/agent-runtime/fireworksai/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/agent-runtime/fireworksai/index.ts b/src/libs/agent-runtime/fireworksai/index.ts index 19879b68eef7..1ce62dfd14dc 100644 --- a/src/libs/agent-runtime/fireworksai/index.ts +++ b/src/libs/agent-runtime/fireworksai/index.ts @@ -22,7 +22,7 @@ export const LobeFireworksAI = LobeOpenAICompatibleFactory({ return { contextWindowTokens: model.context_length, enabled: LOBE_DEFAULT_MODEL_LIST.find((m) => model.id.endsWith(m.id))?.enabled || false, - functionCall: model.supports_tools, + functionCall: model.supports_tools || model.id.toLowerCase().includes('function'), id: model.id, vision: model.supports_image_input, }; From 80a1c4cf5f861cea191bc2c4286359793b1b793c Mon Sep 17 00:00:00 2001 From: Zhijie He Date: Wed, 8 Jan 2025 20:29:14 +0800 Subject: [PATCH 11/21] =?UTF-8?q?=F0=9F=92=84=20style:=20add=20Zhipu=20Fet?= =?UTF-8?q?chModel=20support?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/config/modelProviders/zhipu.ts | 6 ++++- src/libs/agent-runtime/zhipu/index.ts | 35 +++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/src/config/modelProviders/zhipu.ts b/src/config/modelProviders/zhipu.ts index ba0c5733154f..738d72c87fa6 100644 --- a/src/config/modelProviders/zhipu.ts +++ b/src/config/modelProviders/zhipu.ts @@ -211,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/zhipu/index.ts b/src/libs/agent-runtime/zhipu/index.ts index b49060e0166f..08c35e09c44c 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/modelProviders'; +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, }); From 41eb03a87b953c56d0fdcf7213419c4ca163ef70 Mon Sep 17 00:00:00 2001 From: Zhijie He Date: Wed, 8 Jan 2025 21:30:53 +0800 Subject: [PATCH 12/21] =?UTF-8?q?=F0=9F=92=84=20style:=20add=20Anthropic?= =?UTF-8?q?=20FetchModel=20support?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/config/modelProviders/anthropic.ts | 2 ++ src/libs/agent-runtime/anthropic/index.ts | 36 +++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/src/config/modelProviders/anthropic.ts b/src/config/modelProviders/anthropic.ts index 6865e4bb4ffa..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: { @@ -143,6 +144,7 @@ const Anthropic: ModelProviderCard = { placeholder: 'https://api.anthropic.com', }, sdkType: 'anthropic', + showModelFetcher: true, smoothing: { speed: 5, text: true, diff --git a/src/libs/agent-runtime/anthropic/index.ts b/src/libs/agent-runtime/anthropic/index.ts index 240fd2a5cdb9..47490517fc50 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/modelProviders'; +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 = `${DEFAULT_BASE_URL}/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; From adb7234570d670719fbe07a74b3edc382dec91a7 Mon Sep 17 00:00:00 2001 From: Zhijie He Date: Wed, 8 Jan 2025 22:19:55 +0800 Subject: [PATCH 13/21] =?UTF-8?q?=F0=9F=92=84=20style:=20add=20Google=20Mo?= =?UTF-8?q?delFetch=20support?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/config/modelProviders/google.ts | 2 ++ src/libs/agent-runtime/anthropic/index.ts | 2 +- src/libs/agent-runtime/google/index.ts | 41 ++++++++++++++++++++++- 3 files changed, 43 insertions(+), 2 deletions(-) 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/libs/agent-runtime/anthropic/index.ts b/src/libs/agent-runtime/anthropic/index.ts index 47490517fc50..732735e97c82 100644 --- a/src/libs/agent-runtime/anthropic/index.ts +++ b/src/libs/agent-runtime/anthropic/index.ts @@ -114,7 +114,7 @@ export class LobeAnthropicAI implements LobeRuntimeAI { } async models() { - const url = `${DEFAULT_BASE_URL}/v1/models`; + const url = `${this.baseURL}/v1/models`; const response = await fetch(url, { headers: { 'anthropic-version': '2023-06-01', diff --git a/src/libs/agent-runtime/google/index.ts b/src/libs/agent-runtime/google/index.ts index 67b226d2ca9b..d6dbcf667e0b 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/modelProviders'; +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', @@ -38,15 +48,19 @@ enum HarmBlockThreshold { BLOCK_NONE = '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) { @@ -115,6 +129,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'); From 98ed8d7b3f62441e163c0536e99f28a177d5f2ab Mon Sep 17 00:00:00 2001 From: Zhijie He Date: Mon, 13 Jan 2025 22:02:32 +0800 Subject: [PATCH 14/21] =?UTF-8?q?=F0=9F=92=84=20style:=20add=20HuggingFace?= =?UTF-8?q?=20ModelFetch=20support?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/config/modelProviders/huggingface.ts | 2 ++ src/libs/agent-runtime/huggingface/index.ts | 37 +++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/src/config/modelProviders/huggingface.ts b/src/config/modelProviders/huggingface.ts index cba039ac7414..ace8370720c0 100644 --- a/src/config/modelProviders/huggingface.ts +++ b/src/config/modelProviders/huggingface.ts @@ -49,11 +49,13 @@ const HuggingFace: ModelProviderCard = { 'HuggingFace Inference API 提供了一种快速且免费的方式,让您可以探索成千上万种模型,适用于各种任务。无论您是在为新应用程序进行原型设计,还是在尝试机器学习的功能,这个 API 都能让您即时访问多个领域的高性能模型。', disableBrowserRequest: true, id: 'huggingface', + modelList: { showModelFetcher: true }, modelsUrl: 'https://huggingface.co/docs/api-inference/en/supported-models', name: 'HuggingFace', settings: { disableBrowserRequest: true, sdkType: 'huggingface', + showModelFetcher: true, }, url: 'https://huggingface.co', }; diff --git a/src/libs/agent-runtime/huggingface/index.ts b/src/libs/agent-runtime/huggingface/index.ts index 0739830f82fd..77484906172f 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/modelProviders'; +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, }); From 20b6324921843dfd675aa5cf1e90a0d21c127b33 Mon Sep 17 00:00:00 2001 From: Zhijie He Date: Mon, 13 Jan 2025 22:36:19 +0800 Subject: [PATCH 15/21] =?UTF-8?q?=F0=9F=90=9B=20fix:=20fix=20stepfun=20fc?= =?UTF-8?q?=20tag?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/libs/agent-runtime/stepfun/index.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/libs/agent-runtime/stepfun/index.ts b/src/libs/agent-runtime/stepfun/index.ts index 617ef9aa0429..f429d1dc7d86 100644 --- a/src/libs/agent-runtime/stepfun/index.ts +++ b/src/libs/agent-runtime/stepfun/index.ts @@ -22,11 +22,18 @@ export const LobeStepfunAI = LobeOpenAICompatibleFactory({ }, 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: model.id !== 'step-1.5v-mini', + functionCall: functionCallKeywords.some(keyword => model.id.toLowerCase().includes(keyword)), id: model.id, vision: model.id.toLowerCase().includes('v'), }; From 10155f6ec45e24b5816f369b9d9e11dc810a4c0b Mon Sep 17 00:00:00 2001 From: Zhijie He Date: Wed, 15 Jan 2025 06:40:44 +0800 Subject: [PATCH 16/21] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20refactor:=20refactor?= =?UTF-8?q?=20`LOBE=5FDEFAULT=5FMODEL=5FLIST`=20import?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/libs/agent-runtime/ai360/index.ts | 2 +- src/libs/agent-runtime/anthropic/index.ts | 2 +- src/libs/agent-runtime/baichuan/index.ts | 2 +- src/libs/agent-runtime/deepseek/index.ts | 2 +- src/libs/agent-runtime/fireworksai/index.ts | 2 +- src/libs/agent-runtime/giteeai/index.ts | 2 +- src/libs/agent-runtime/github/index.ts | 2 +- src/libs/agent-runtime/google/index.ts | 2 +- src/libs/agent-runtime/groq/index.ts | 2 +- src/libs/agent-runtime/higress/index.ts | 2 +- src/libs/agent-runtime/huggingface/index.ts | 2 +- src/libs/agent-runtime/internlm/index.ts | 2 +- src/libs/agent-runtime/mistral/index.ts | 2 +- src/libs/agent-runtime/moonshot/index.ts | 2 +- src/libs/agent-runtime/openrouter/index.ts | 2 +- src/libs/agent-runtime/qwen/index.ts | 2 +- src/libs/agent-runtime/sensenova/index.ts | 2 +- src/libs/agent-runtime/siliconcloud/index.ts | 2 +- src/libs/agent-runtime/stepfun/index.ts | 2 +- src/libs/agent-runtime/togetherai/index.ts | 2 +- src/libs/agent-runtime/utils/openaiCompatibleFactory/index.ts | 2 +- src/libs/agent-runtime/xai/index.ts | 2 +- src/libs/agent-runtime/zeroone/index.ts | 2 +- src/libs/agent-runtime/zhipu/index.ts | 2 +- 24 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/libs/agent-runtime/ai360/index.ts b/src/libs/agent-runtime/ai360/index.ts index 8cc18c87055d..efaf1d831e0e 100644 --- a/src/libs/agent-runtime/ai360/index.ts +++ b/src/libs/agent-runtime/ai360/index.ts @@ -1,7 +1,7 @@ import { ModelProvider } from '../types'; import { LobeOpenAICompatibleFactory } from '../utils/openaiCompatibleFactory'; -import { LOBE_DEFAULT_MODEL_LIST } from '@/config/modelProviders'; +import { LOBE_DEFAULT_MODEL_LIST } from '@/config/aiModels'; export interface Ai360ModelCard { id: string; diff --git a/src/libs/agent-runtime/anthropic/index.ts b/src/libs/agent-runtime/anthropic/index.ts index 732735e97c82..e2a6d2cb29ff 100644 --- a/src/libs/agent-runtime/anthropic/index.ts +++ b/src/libs/agent-runtime/anthropic/index.ts @@ -13,7 +13,7 @@ import { buildAnthropicMessages, buildAnthropicTools } from '../utils/anthropicH import { StreamingResponse } from '../utils/response'; import { AnthropicStream } from '../utils/streams'; -import { LOBE_DEFAULT_MODEL_LIST } from '@/config/modelProviders'; +import { LOBE_DEFAULT_MODEL_LIST } from '@/config/aiModels'; import type { ChatModelCard } from '@/types/llm'; export interface AnthropicModelCard { diff --git a/src/libs/agent-runtime/baichuan/index.ts b/src/libs/agent-runtime/baichuan/index.ts index 649308edb7af..160adb7ed2c1 100644 --- a/src/libs/agent-runtime/baichuan/index.ts +++ b/src/libs/agent-runtime/baichuan/index.ts @@ -3,7 +3,7 @@ import OpenAI from 'openai'; import { ChatStreamPayload, ModelProvider } from '../types'; import { LobeOpenAICompatibleFactory } from '../utils/openaiCompatibleFactory'; -import { LOBE_DEFAULT_MODEL_LIST } from '@/config/modelProviders'; +import { LOBE_DEFAULT_MODEL_LIST } from '@/config/aiModels'; import type { ChatModelCard } from '@/types/llm'; export interface BaichuanModelCard { diff --git a/src/libs/agent-runtime/deepseek/index.ts b/src/libs/agent-runtime/deepseek/index.ts index 5c29b0a8cf4b..0f8eef2458a6 100644 --- a/src/libs/agent-runtime/deepseek/index.ts +++ b/src/libs/agent-runtime/deepseek/index.ts @@ -1,7 +1,7 @@ import { ModelProvider } from '../types'; import { LobeOpenAICompatibleFactory } from '../utils/openaiCompatibleFactory'; -import { LOBE_DEFAULT_MODEL_LIST } from '@/config/modelProviders'; +import { LOBE_DEFAULT_MODEL_LIST } from '@/config/aiModels'; export interface DeepSeekModelCard { id: string; diff --git a/src/libs/agent-runtime/fireworksai/index.ts b/src/libs/agent-runtime/fireworksai/index.ts index 1ce62dfd14dc..661a2ec555fc 100644 --- a/src/libs/agent-runtime/fireworksai/index.ts +++ b/src/libs/agent-runtime/fireworksai/index.ts @@ -1,7 +1,7 @@ import { ModelProvider } from '../types'; import { LobeOpenAICompatibleFactory } from '../utils/openaiCompatibleFactory'; -import { LOBE_DEFAULT_MODEL_LIST } from '@/config/modelProviders'; +import { LOBE_DEFAULT_MODEL_LIST } from '@/config/aiModels'; export interface FireworksAIModelCard { context_length: number; diff --git a/src/libs/agent-runtime/giteeai/index.ts b/src/libs/agent-runtime/giteeai/index.ts index e8749a12b3c0..590a5b65b2f9 100644 --- a/src/libs/agent-runtime/giteeai/index.ts +++ b/src/libs/agent-runtime/giteeai/index.ts @@ -1,7 +1,7 @@ import { ModelProvider } from '../types'; import { LobeOpenAICompatibleFactory } from '../utils/openaiCompatibleFactory'; -import { LOBE_DEFAULT_MODEL_LIST } from '@/config/modelProviders'; +import { LOBE_DEFAULT_MODEL_LIST } from '@/config/aiModels'; export interface GiteeAIModelCard { id: string; diff --git a/src/libs/agent-runtime/github/index.ts b/src/libs/agent-runtime/github/index.ts index 7081a73043ef..574562b262d9 100644 --- a/src/libs/agent-runtime/github/index.ts +++ b/src/libs/agent-runtime/github/index.ts @@ -1,4 +1,4 @@ -import { LOBE_DEFAULT_MODEL_LIST } from '@/config/modelProviders'; +import { LOBE_DEFAULT_MODEL_LIST } from '@/config/aiModels'; import type { ChatModelCard } from '@/types/llm'; import { AgentRuntimeErrorType } from '../error'; diff --git a/src/libs/agent-runtime/google/index.ts b/src/libs/agent-runtime/google/index.ts index d6dbcf667e0b..482b69513644 100644 --- a/src/libs/agent-runtime/google/index.ts +++ b/src/libs/agent-runtime/google/index.ts @@ -27,7 +27,7 @@ import { StreamingResponse } from '../utils/response'; import { GoogleGenerativeAIStream, convertIterableToStream } from '../utils/streams'; import { parseDataUri } from '../utils/uriParser'; -import { LOBE_DEFAULT_MODEL_LIST } from '@/config/modelProviders'; +import { LOBE_DEFAULT_MODEL_LIST } from '@/config/aiModels'; import type { ChatModelCard } from '@/types/llm'; export interface GoogleModelCard { diff --git a/src/libs/agent-runtime/groq/index.ts b/src/libs/agent-runtime/groq/index.ts index 271014f12f9b..473255acbd98 100644 --- a/src/libs/agent-runtime/groq/index.ts +++ b/src/libs/agent-runtime/groq/index.ts @@ -2,7 +2,7 @@ import { AgentRuntimeErrorType } from '../error'; import { ModelProvider } from '../types'; import { LobeOpenAICompatibleFactory } from '../utils/openaiCompatibleFactory'; -import { LOBE_DEFAULT_MODEL_LIST } from '@/config/modelProviders'; +import { LOBE_DEFAULT_MODEL_LIST } from '@/config/aiModels'; export interface GroqModelCard { context_window: number; diff --git a/src/libs/agent-runtime/higress/index.ts b/src/libs/agent-runtime/higress/index.ts index 6b591ffe8357..7faa4dfbf517 100644 --- a/src/libs/agent-runtime/higress/index.ts +++ b/src/libs/agent-runtime/higress/index.ts @@ -1,6 +1,6 @@ import { uniqueId } from 'lodash-es'; -import { LOBE_DEFAULT_MODEL_LIST } from '@/config/modelProviders'; +import { LOBE_DEFAULT_MODEL_LIST } from '@/config/aiModels'; import { ModelProvider } from '../types'; import { LobeOpenAICompatibleFactory } from '../utils/openaiCompatibleFactory'; diff --git a/src/libs/agent-runtime/huggingface/index.ts b/src/libs/agent-runtime/huggingface/index.ts index 77484906172f..c5b6d3cf59d1 100644 --- a/src/libs/agent-runtime/huggingface/index.ts +++ b/src/libs/agent-runtime/huggingface/index.ts @@ -6,7 +6,7 @@ import { ModelProvider } from '../types'; import { LobeOpenAICompatibleFactory } from '../utils/openaiCompatibleFactory'; import { convertIterableToStream } from '../utils/streams'; -import { LOBE_DEFAULT_MODEL_LIST } from '@/config/modelProviders'; +import { LOBE_DEFAULT_MODEL_LIST } from '@/config/aiModels'; import type { ChatModelCard } from '@/types/llm'; export interface HuggingFaceModelCard { diff --git a/src/libs/agent-runtime/internlm/index.ts b/src/libs/agent-runtime/internlm/index.ts index 7610da9e3c2d..0c590ee4d46d 100644 --- a/src/libs/agent-runtime/internlm/index.ts +++ b/src/libs/agent-runtime/internlm/index.ts @@ -1,7 +1,7 @@ import { ModelProvider } from '../types'; import { LobeOpenAICompatibleFactory } from '../utils/openaiCompatibleFactory'; -import { LOBE_DEFAULT_MODEL_LIST } from '@/config/modelProviders'; +import { LOBE_DEFAULT_MODEL_LIST } from '@/config/aiModels'; export interface InternLMModelCard { id: string; diff --git a/src/libs/agent-runtime/mistral/index.ts b/src/libs/agent-runtime/mistral/index.ts index 723206e70e65..3c76a0d34a3a 100644 --- a/src/libs/agent-runtime/mistral/index.ts +++ b/src/libs/agent-runtime/mistral/index.ts @@ -1,7 +1,7 @@ import { ModelProvider } from '../types'; import { LobeOpenAICompatibleFactory } from '../utils/openaiCompatibleFactory'; -import { LOBE_DEFAULT_MODEL_LIST } from '@/config/modelProviders'; +import { LOBE_DEFAULT_MODEL_LIST } from '@/config/aiModels'; export interface MistralModelCard { capabilities: { diff --git a/src/libs/agent-runtime/moonshot/index.ts b/src/libs/agent-runtime/moonshot/index.ts index 9e024190762a..67930511ae98 100644 --- a/src/libs/agent-runtime/moonshot/index.ts +++ b/src/libs/agent-runtime/moonshot/index.ts @@ -3,7 +3,7 @@ import OpenAI from 'openai'; import { ChatStreamPayload, ModelProvider } from '../types'; import { LobeOpenAICompatibleFactory } from '../utils/openaiCompatibleFactory'; -import { LOBE_DEFAULT_MODEL_LIST } from '@/config/modelProviders'; +import { LOBE_DEFAULT_MODEL_LIST } from '@/config/aiModels'; export interface MoonshotModelCard { id: string; diff --git a/src/libs/agent-runtime/openrouter/index.ts b/src/libs/agent-runtime/openrouter/index.ts index 02d935d45d3b..62b487347a80 100644 --- a/src/libs/agent-runtime/openrouter/index.ts +++ b/src/libs/agent-runtime/openrouter/index.ts @@ -1,4 +1,4 @@ -import { LOBE_DEFAULT_MODEL_LIST } from '@/config/modelProviders'; +import { LOBE_DEFAULT_MODEL_LIST } from '@/config/aiModels'; import { ModelProvider } from '../types'; import { LobeOpenAICompatibleFactory } from '../utils/openaiCompatibleFactory'; diff --git a/src/libs/agent-runtime/qwen/index.ts b/src/libs/agent-runtime/qwen/index.ts index 0dbcac08168c..6f813b775494 100644 --- a/src/libs/agent-runtime/qwen/index.ts +++ b/src/libs/agent-runtime/qwen/index.ts @@ -3,7 +3,7 @@ import { LobeOpenAICompatibleFactory } from '../utils/openaiCompatibleFactory'; import { QwenAIStream } from '../utils/streams'; -import { LOBE_DEFAULT_MODEL_LIST } from '@/config/modelProviders'; +import { LOBE_DEFAULT_MODEL_LIST } from '@/config/aiModels'; export interface QwenModelCard { id: string; diff --git a/src/libs/agent-runtime/sensenova/index.ts b/src/libs/agent-runtime/sensenova/index.ts index ae7d174c6d21..050f6b09922e 100644 --- a/src/libs/agent-runtime/sensenova/index.ts +++ b/src/libs/agent-runtime/sensenova/index.ts @@ -1,7 +1,7 @@ import { ModelProvider } from '../types'; import { LobeOpenAICompatibleFactory } from '../utils/openaiCompatibleFactory'; -import { LOBE_DEFAULT_MODEL_LIST } from '@/config/modelProviders'; +import { LOBE_DEFAULT_MODEL_LIST } from '@/config/aiModels'; import type { ChatModelCard } from '@/types/llm'; export interface SenseNovaModelCard { diff --git a/src/libs/agent-runtime/siliconcloud/index.ts b/src/libs/agent-runtime/siliconcloud/index.ts index f3b6495f1f87..bf0bd65891b2 100644 --- a/src/libs/agent-runtime/siliconcloud/index.ts +++ b/src/libs/agent-runtime/siliconcloud/index.ts @@ -1,7 +1,7 @@ import { ModelProvider } from '../types'; import { LobeOpenAICompatibleFactory } from '../utils/openaiCompatibleFactory'; -import { LOBE_DEFAULT_MODEL_LIST } from '@/config/modelProviders'; +import { LOBE_DEFAULT_MODEL_LIST } from '@/config/aiModels'; export interface SiliconCloudModelCard { id: string; diff --git a/src/libs/agent-runtime/stepfun/index.ts b/src/libs/agent-runtime/stepfun/index.ts index f429d1dc7d86..2078cbc3c3c6 100644 --- a/src/libs/agent-runtime/stepfun/index.ts +++ b/src/libs/agent-runtime/stepfun/index.ts @@ -1,7 +1,7 @@ import { ModelProvider } from '../types'; import { LobeOpenAICompatibleFactory } from '../utils/openaiCompatibleFactory'; -import { LOBE_DEFAULT_MODEL_LIST } from '@/config/modelProviders'; +import { LOBE_DEFAULT_MODEL_LIST } from '@/config/aiModels'; export interface StepfunModelCard { id: string; diff --git a/src/libs/agent-runtime/togetherai/index.ts b/src/libs/agent-runtime/togetherai/index.ts index 73b06cbcd314..8e8f854d37af 100644 --- a/src/libs/agent-runtime/togetherai/index.ts +++ b/src/libs/agent-runtime/togetherai/index.ts @@ -1,4 +1,4 @@ -import { LOBE_DEFAULT_MODEL_LIST } from '@/config/modelProviders'; +import { LOBE_DEFAULT_MODEL_LIST } from '@/config/aiModels'; import { ModelProvider } from '../types'; import { LobeOpenAICompatibleFactory } from '../utils/openaiCompatibleFactory'; diff --git a/src/libs/agent-runtime/utils/openaiCompatibleFactory/index.ts b/src/libs/agent-runtime/utils/openaiCompatibleFactory/index.ts index 48eef0beef3a..daf130e1326f 100644 --- a/src/libs/agent-runtime/utils/openaiCompatibleFactory/index.ts +++ b/src/libs/agent-runtime/utils/openaiCompatibleFactory/index.ts @@ -3,7 +3,7 @@ import utc from 'dayjs/plugin/utc'; import OpenAI, { ClientOptions } from 'openai'; import { Stream } from 'openai/streaming'; -import { LOBE_DEFAULT_MODEL_LIST } from '@/config/modelProviders'; +import { LOBE_DEFAULT_MODEL_LIST } from '@/config/aiModels'; import type { ChatModelCard } from '@/types/llm'; import { LobeRuntimeAI } from '../../BaseAI'; diff --git a/src/libs/agent-runtime/xai/index.ts b/src/libs/agent-runtime/xai/index.ts index fe896a5eba97..5602869e4351 100644 --- a/src/libs/agent-runtime/xai/index.ts +++ b/src/libs/agent-runtime/xai/index.ts @@ -1,7 +1,7 @@ import { ModelProvider } from '../types'; import { LobeOpenAICompatibleFactory } from '../utils/openaiCompatibleFactory'; -import { LOBE_DEFAULT_MODEL_LIST } from '@/config/modelProviders'; +import { LOBE_DEFAULT_MODEL_LIST } from '@/config/aiModels'; export interface XAIModelCard { id: string; diff --git a/src/libs/agent-runtime/zeroone/index.ts b/src/libs/agent-runtime/zeroone/index.ts index 50f1cd48eed4..fb8ab88c550a 100644 --- a/src/libs/agent-runtime/zeroone/index.ts +++ b/src/libs/agent-runtime/zeroone/index.ts @@ -1,7 +1,7 @@ import { ModelProvider } from '../types'; import { LobeOpenAICompatibleFactory } from '../utils/openaiCompatibleFactory'; -import { LOBE_DEFAULT_MODEL_LIST } from '@/config/modelProviders'; +import { LOBE_DEFAULT_MODEL_LIST } from '@/config/aiModels'; export interface ZeroOneModelCard { id: string; diff --git a/src/libs/agent-runtime/zhipu/index.ts b/src/libs/agent-runtime/zhipu/index.ts index 08c35e09c44c..3003fe0d9374 100644 --- a/src/libs/agent-runtime/zhipu/index.ts +++ b/src/libs/agent-runtime/zhipu/index.ts @@ -3,7 +3,7 @@ import OpenAI from 'openai'; import { ChatStreamPayload, ModelProvider } from '../types'; import { LobeOpenAICompatibleFactory } from '../utils/openaiCompatibleFactory'; -import { LOBE_DEFAULT_MODEL_LIST } from '@/config/modelProviders'; +import { LOBE_DEFAULT_MODEL_LIST } from '@/config/aiModels'; import type { ChatModelCard } from '@/types/llm'; export interface ZhipuModelCard { From 8e73626f3e6befe2073919b5efeaaafc607e9529 Mon Sep 17 00:00:00 2001 From: Zhijie He Date: Wed, 15 Jan 2025 10:21:47 +0800 Subject: [PATCH 17/21] =?UTF-8?q?=F0=9F=94=A8=20chore:=20revert=20some=20c?= =?UTF-8?q?hanges?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/libs/agent-runtime/github/index.ts | 2 +- src/libs/agent-runtime/higress/index.ts | 2 +- src/libs/agent-runtime/openrouter/index.ts | 2 +- src/libs/agent-runtime/togetherai/index.ts | 2 +- src/libs/agent-runtime/utils/openaiCompatibleFactory/index.ts | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/libs/agent-runtime/github/index.ts b/src/libs/agent-runtime/github/index.ts index 574562b262d9..7081a73043ef 100644 --- a/src/libs/agent-runtime/github/index.ts +++ b/src/libs/agent-runtime/github/index.ts @@ -1,4 +1,4 @@ -import { LOBE_DEFAULT_MODEL_LIST } from '@/config/aiModels'; +import { LOBE_DEFAULT_MODEL_LIST } from '@/config/modelProviders'; import type { ChatModelCard } from '@/types/llm'; import { AgentRuntimeErrorType } from '../error'; diff --git a/src/libs/agent-runtime/higress/index.ts b/src/libs/agent-runtime/higress/index.ts index 7faa4dfbf517..6b591ffe8357 100644 --- a/src/libs/agent-runtime/higress/index.ts +++ b/src/libs/agent-runtime/higress/index.ts @@ -1,6 +1,6 @@ import { uniqueId } from 'lodash-es'; -import { LOBE_DEFAULT_MODEL_LIST } from '@/config/aiModels'; +import { LOBE_DEFAULT_MODEL_LIST } from '@/config/modelProviders'; import { ModelProvider } from '../types'; import { LobeOpenAICompatibleFactory } from '../utils/openaiCompatibleFactory'; diff --git a/src/libs/agent-runtime/openrouter/index.ts b/src/libs/agent-runtime/openrouter/index.ts index 62b487347a80..02d935d45d3b 100644 --- a/src/libs/agent-runtime/openrouter/index.ts +++ b/src/libs/agent-runtime/openrouter/index.ts @@ -1,4 +1,4 @@ -import { LOBE_DEFAULT_MODEL_LIST } from '@/config/aiModels'; +import { LOBE_DEFAULT_MODEL_LIST } from '@/config/modelProviders'; import { ModelProvider } from '../types'; import { LobeOpenAICompatibleFactory } from '../utils/openaiCompatibleFactory'; diff --git a/src/libs/agent-runtime/togetherai/index.ts b/src/libs/agent-runtime/togetherai/index.ts index 8e8f854d37af..73b06cbcd314 100644 --- a/src/libs/agent-runtime/togetherai/index.ts +++ b/src/libs/agent-runtime/togetherai/index.ts @@ -1,4 +1,4 @@ -import { LOBE_DEFAULT_MODEL_LIST } from '@/config/aiModels'; +import { LOBE_DEFAULT_MODEL_LIST } from '@/config/modelProviders'; import { ModelProvider } from '../types'; import { LobeOpenAICompatibleFactory } from '../utils/openaiCompatibleFactory'; diff --git a/src/libs/agent-runtime/utils/openaiCompatibleFactory/index.ts b/src/libs/agent-runtime/utils/openaiCompatibleFactory/index.ts index 1b54212c44c6..e2b70de94997 100644 --- a/src/libs/agent-runtime/utils/openaiCompatibleFactory/index.ts +++ b/src/libs/agent-runtime/utils/openaiCompatibleFactory/index.ts @@ -3,7 +3,7 @@ import utc from 'dayjs/plugin/utc'; import OpenAI, { ClientOptions } from 'openai'; import { Stream } from 'openai/streaming'; -import { LOBE_DEFAULT_MODEL_LIST } from '@/config/aiModels'; +import { LOBE_DEFAULT_MODEL_LIST } from '@/config/modelProviders'; import type { ChatModelCard } from '@/types/llm'; import { LobeRuntimeAI } from '../../BaseAI'; From a448c61ab2f1733ec57a8a7beea8ce1a32bfa438 Mon Sep 17 00:00:00 2001 From: Zhijie He Date: Wed, 15 Jan 2025 10:30:08 +0800 Subject: [PATCH 18/21] =?UTF-8?q?=F0=9F=90=9B=20fix:=20fix=20aiModels=20im?= =?UTF-8?q?port?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/libs/agent-runtime/minimax/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/agent-runtime/minimax/index.ts b/src/libs/agent-runtime/minimax/index.ts index ab43b0aff9ff..44cddf972f72 100644 --- a/src/libs/agent-runtime/minimax/index.ts +++ b/src/libs/agent-runtime/minimax/index.ts @@ -1,7 +1,7 @@ import { ModelProvider } from '../types'; import { LobeOpenAICompatibleFactory } from '../utils/openaiCompatibleFactory'; -import Minimax from '@/config/modelProviders/minimax'; +import Minimax from '@/config/aiModels/minimax'; export const getMinimaxMaxOutputs = (modelId: string): number | undefined => { const model = Minimax.chatModels.find(model => model.id === modelId); From 48a70c511ba67c468e929ccf729ef0b30754b12a Mon Sep 17 00:00:00 2001 From: Zhijie He Date: Wed, 15 Jan 2025 10:38:24 +0800 Subject: [PATCH 19/21] =?UTF-8?q?=F0=9F=90=9B=20fix:=20fix=20CI=20error?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/libs/agent-runtime/minimax/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/agent-runtime/minimax/index.ts b/src/libs/agent-runtime/minimax/index.ts index 44cddf972f72..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/aiModels/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; }; From d6fd159668a8ce952672b4cdfec6edef8fa3669e Mon Sep 17 00:00:00 2001 From: Zhijie He Date: Wed, 15 Jan 2025 11:01:25 +0800 Subject: [PATCH 20/21] =?UTF-8?q?=F0=9F=92=84=20style:=20add=20`MiniMax-Te?= =?UTF-8?q?xt-01`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/config/aiModels/minimax.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) 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, From c71e6731d8d13476b760cbae6f3d58f0f7f41950 Mon Sep 17 00:00:00 2001 From: Zhijie He Date: Wed, 15 Jan 2025 11:25:38 +0800 Subject: [PATCH 21/21] =?UTF-8?q?=F0=9F=92=84=20style:=20add=20vision=20mo?= =?UTF-8?q?del=20support=20for=20Moonshot?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update moonshot.ts * Update index.ts * Update moonshot.ts --- src/config/aiModels/moonshot.ts | 74 +++++++++++++++++++++++- src/libs/agent-runtime/moonshot/index.ts | 1 + 2 files changed, 74 insertions(+), 1 deletion(-) 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/libs/agent-runtime/moonshot/index.ts b/src/libs/agent-runtime/moonshot/index.ts index 67930511ae98..9bb015e9e91e 100644 --- a/src/libs/agent-runtime/moonshot/index.ts +++ b/src/libs/agent-runtime/moonshot/index.ts @@ -32,6 +32,7 @@ export const LobeMoonshotAI = LobeOpenAICompatibleFactory({ 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'), }; }, },