-
-
Notifications
You must be signed in to change notification settings - Fork 11.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ feat: add Nvidia NIM provider support (#6142)
* ✨ feat: add Nvidia NIM provider support * 🐛 fix: fix build error * 🔨 chore: sort code * 💄 style: update model list * 🐛 fix: fix ci error
- Loading branch information
1 parent
bf6699c
commit ab796a7
Showing
12 changed files
with
248 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
import { AIChatModelCard } from '@/types/aiModel'; | ||
|
||
const nvidiaChatModels: AIChatModelCard[] = [ | ||
{ | ||
abilities: { | ||
functionCall: true, | ||
}, | ||
contextWindowTokens: 128_000, | ||
description: '先进的 LLM,擅长推理、数学、常识和函数调用。', | ||
displayName: 'Llama 3.3 70B Instruct', | ||
enabled: true, | ||
id: 'meta/llama-3.3-70b-instruct', | ||
type: 'chat' | ||
}, | ||
{ | ||
contextWindowTokens: 128_000, | ||
description: '先进的最尖端小型语言模型,具备语言理解、卓越的推理能力和文本生成能力。', | ||
displayName: 'Llama 3.2 1B Instruct', | ||
id: 'meta/llama-3.2-1b-instruct', | ||
type: 'chat' | ||
}, | ||
{ | ||
contextWindowTokens: 128_000, | ||
description: '先进的最尖端小型语言模型,具备语言理解、卓越的推理能力和文本生成能力。', | ||
displayName: 'Llama 3.2 3B Instruct', | ||
id: 'meta/llama-3.2-3b-instruct', | ||
type: 'chat' | ||
}, | ||
{ | ||
abilities: { | ||
vision: true, | ||
}, | ||
contextWindowTokens: 128_000, | ||
description: '尖端的视觉-语言模型,擅长从图像中进行高质量推理。', | ||
displayName: 'Llama 3.2 11B Vision Instruct', | ||
enabled: true, | ||
id: 'meta/llama-3.2-11b-vision-instruct', | ||
type: 'chat' | ||
}, | ||
{ | ||
abilities: { | ||
vision: true, | ||
}, | ||
contextWindowTokens: 128_000, | ||
description: '尖端的视觉-语言模型,擅长从图像中进行高质量推理。', | ||
displayName: 'Llama 3.2 90B Vision Instruct', | ||
id: 'meta/llama-3.2-90b-vision-instruct', | ||
type: 'chat' | ||
}, | ||
{ | ||
abilities: { | ||
functionCall: true, | ||
}, | ||
contextWindowTokens: 128_000, | ||
description: '先进的最尖端模型,具备语言理解、卓越的推理能力和文本生成能力。', | ||
displayName: 'Llama 3.1 8B Instruct', | ||
id: 'meta/llama-3.1-8b-instruct', | ||
type: 'chat' | ||
}, | ||
{ | ||
abilities: { | ||
functionCall: true, | ||
}, | ||
contextWindowTokens: 128_000, | ||
description: '赋能复杂对话,具备卓越的上下文理解、推理能力和文本生成能力。', | ||
displayName: 'Llama 3.1 70B Instruct', | ||
id: 'meta/llama-3.1-70b-instruct', | ||
type: 'chat' | ||
}, | ||
{ | ||
abilities: { | ||
functionCall: true, | ||
}, | ||
contextWindowTokens: 128_000, | ||
description: '高级 LLM,支持合成数据生成、知识蒸馏和推理,适用于聊天机器人、编程和特定领域任务。', | ||
displayName: 'Llama 3.1 405B Instruct', | ||
id: 'meta/llama-3.1-405b-instruct', | ||
type: 'chat' | ||
}, | ||
{ | ||
contextWindowTokens: 32_768, | ||
description: '独特的语言模型,提供无与伦比的准确性和效率表现。', | ||
displayName: 'Llama 3.1 Nemotron 51B Instruct', | ||
id: 'nvidia/llama-3.1-nemotron-51b-instruct', | ||
type: 'chat' | ||
}, | ||
{ | ||
contextWindowTokens: 32_768, | ||
description: 'Llama-3.1-Nemotron-70B-Instruct 是 NVIDIA 定制的大型语言模型,旨在提高 LLM 生成的响应的帮助性。', | ||
displayName: 'Llama 3.1 Nemotron 70B Instruct', | ||
id: 'nvidia/llama-3.1-nemotron-70b-instruct', | ||
type: 'chat' | ||
}, | ||
{ | ||
contextWindowTokens: 8192, | ||
description: '面向边缘应用的高级小型语言生成 AI 模型。', | ||
displayName: 'Gemma 2 2B Instruct', | ||
id: 'google/gemma-2-2b-it', | ||
type: 'chat' | ||
}, | ||
{ | ||
contextWindowTokens: 8192, | ||
description: '尖端文本生成模型,擅长文本理解、转换和代码生成。', | ||
displayName: 'Gemma 2 9B Instruct', | ||
id: 'google/gemma-2-9b-it', | ||
type: 'chat' | ||
}, | ||
{ | ||
contextWindowTokens: 8192, | ||
description: '尖端文本生成模型,擅长文本理解、转换和代码生成。', | ||
displayName: 'Gemma 2 27B Instruct', | ||
id: 'google/gemma-2-27b-it', | ||
type: 'chat' | ||
}, | ||
{ | ||
abilities: { | ||
reasoning: true, | ||
}, | ||
contextWindowTokens: 128_000, | ||
description: '最先进的高效 LLM,擅长推理、数学和编程。', | ||
displayName: 'DeepSeek R1', | ||
enabled: true, | ||
id: 'deepseek-ai/deepseek-r1', | ||
type: 'chat' | ||
}, | ||
{ | ||
abilities: { | ||
functionCall: true, | ||
}, | ||
contextWindowTokens: 32_768, | ||
description: '面向中文和英文的 LLM,针对语言、编程、数学、推理等领域。', | ||
displayName: 'Qwen2.5 7B Instruct', | ||
enabled: true, | ||
id: 'qwen/qwen2.5-7b-instruct', | ||
type: 'chat' | ||
}, | ||
{ | ||
contextWindowTokens: 32_768, | ||
description: '强大的中型代码模型,支持 32K 上下文长度,擅长多语言编程。', | ||
displayName: 'Qwen2.5 Coder 7B Instruct', | ||
id: 'qwen/qwen2.5-coder-7b-instruct', | ||
type: 'chat' | ||
}, | ||
{ | ||
contextWindowTokens: 32_768, | ||
description: '高级 LLM,支持代码生成、推理和修复,涵盖主流编程语言。', | ||
displayName: 'Qwen2.5 Coder 32B Instruct', | ||
id: 'qwen/qwen2.5-coder-32b-instruct', | ||
type: 'chat' | ||
}, | ||
] | ||
|
||
export const allModels = [...nvidiaChatModels]; | ||
|
||
export default allModels; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { ModelProviderCard } from '@/types/llm'; | ||
|
||
const Nvidia: ModelProviderCard = { | ||
chatModels: [], | ||
checkModel: 'meta/llama-3.2-1b-instruct', | ||
description: 'NVIDIA NIM™ 提供容器,可用于自托管 GPU 加速推理微服务,支持在云端、数据中心、RTX™ AI 个人电脑和工作站上部署预训练和自定义 AI 模型。', | ||
id: 'nvidia', | ||
modelList: { showModelFetcher: true }, | ||
modelsUrl: 'https://build.nvidia.com/models', | ||
name: 'Nvidia', | ||
settings: { | ||
proxyUrl: { | ||
placeholder: 'https://integrate.api.nvidia.com/v1', | ||
}, | ||
sdkType: 'openai', | ||
showModelFetcher: true, | ||
}, | ||
url: 'https://build.nvidia.com', | ||
}; | ||
|
||
export default Nvidia; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { ModelProvider } from '../types'; | ||
import { LobeOpenAICompatibleFactory } from '../utils/openaiCompatibleFactory'; | ||
|
||
import type { ChatModelCard } from '@/types/llm'; | ||
|
||
export interface NvidiaModelCard { | ||
id: string; | ||
} | ||
|
||
export const LobeNvidiaAI = LobeOpenAICompatibleFactory({ | ||
baseURL: 'https://integrate.api.nvidia.com/v1', | ||
debug: { | ||
chatCompletion: () => process.env.DEBUG_NVIDIA_CHAT_COMPLETION === '1', | ||
}, | ||
models: async ({ client }) => { | ||
const { LOBE_DEFAULT_MODEL_LIST } = await import('@/config/aiModels'); | ||
|
||
const modelsPage = await client.models.list() as any; | ||
const modelList: NvidiaModelCard[] = modelsPage.data; | ||
|
||
return modelList | ||
.map((model) => { | ||
const knownModel = LOBE_DEFAULT_MODEL_LIST.find((m) => model.id.toLowerCase() === m.id.toLowerCase()); | ||
|
||
return { | ||
contextWindowTokens: knownModel?.contextWindowTokens ?? undefined, | ||
displayName: knownModel?.displayName ?? undefined, | ||
enabled: knownModel?.enabled || false, | ||
functionCall: | ||
knownModel?.abilities?.functionCall | ||
|| false, | ||
id: model.id, | ||
reasoning: | ||
knownModel?.abilities?.reasoning | ||
|| false, | ||
vision: | ||
knownModel?.abilities?.vision | ||
|| false, | ||
}; | ||
}) | ||
.filter(Boolean) as ChatModelCard[]; | ||
}, | ||
provider: ModelProvider.Nvidia, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters