Skip to content

Commit a46eadf

Browse files
authored
✨ feat: add SambaNova provider support (#6218)
* ✨ feat: add SambaNova provider support * 🐛 fix: fix build error * 🔨 chore: disable Browser Request & `DeepSeek-R1` model
1 parent e061a20 commit a46eadf

File tree

12 files changed

+251
-0
lines changed

12 files changed

+251
-0
lines changed

Dockerfile

+2
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,8 @@ ENV \
205205
PERPLEXITY_API_KEY="" PERPLEXITY_MODEL_LIST="" PERPLEXITY_PROXY_URL="" \
206206
# Qwen
207207
QWEN_API_KEY="" QWEN_MODEL_LIST="" QWEN_PROXY_URL="" \
208+
# SambaNova
209+
SAMBANOVA_API_KEY="" SAMBANOVA_MODEL_LIST="" \
208210
# SenseNova
209211
SENSENOVA_API_KEY="" SENSENOVA_MODEL_LIST="" \
210212
# SiliconCloud

Dockerfile.database

+2
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,8 @@ ENV \
242242
PERPLEXITY_API_KEY="" PERPLEXITY_MODEL_LIST="" PERPLEXITY_PROXY_URL="" \
243243
# Qwen
244244
QWEN_API_KEY="" QWEN_MODEL_LIST="" QWEN_PROXY_URL="" \
245+
# SambaNova
246+
SAMBANOVA_API_KEY="" SAMBANOVA_MODEL_LIST="" \
245247
# SenseNova
246248
SENSENOVA_API_KEY="" SENSENOVA_MODEL_LIST="" \
247249
# SiliconCloud

src/app/[variants]/(main)/settings/llm/ProviderList/providers.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
OpenRouterProviderCard,
2323
PerplexityProviderCard,
2424
QwenProviderCard,
25+
SambaNovaProviderCard,
2526
SenseNovaProviderCard,
2627
SiliconCloudProviderCard,
2728
SparkProviderCard,
@@ -79,6 +80,7 @@ export const useProviderList = (): ProviderItem[] => {
7980
UpstageProviderCard,
8081
XAIProviderCard,
8182
JinaProviderCard,
83+
SambaNovaProviderCard,
8284
QwenProviderCard,
8385
WenxinProviderCard,
8486
HunyuanProviderCard,

src/config/aiModels/index.ts

+3
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import { default as openai } from './openai';
3131
import { default as openrouter } from './openrouter';
3232
import { default as perplexity } from './perplexity';
3333
import { default as qwen } from './qwen';
34+
import { default as sambanova } from './sambanova';
3435
import { default as sensenova } from './sensenova';
3536
import { default as siliconcloud } from './siliconcloud';
3637
import { default as spark } from './spark';
@@ -97,6 +98,7 @@ export const LOBE_DEFAULT_MODEL_LIST = buildDefaultModelList({
9798
openrouter,
9899
perplexity,
99100
qwen,
101+
sambanova,
100102
sensenova,
101103
siliconcloud,
102104
spark,
@@ -144,6 +146,7 @@ export { default as openai } from './openai';
144146
export { default as openrouter } from './openrouter';
145147
export { default as perplexity } from './perplexity';
146148
export { default as qwen } from './qwen';
149+
export { default as sambanova } from './sambanova';
147150
export { default as sensenova } from './sensenova';
148151
export { default as siliconcloud } from './siliconcloud';
149152
export { default as spark } from './spark';

src/config/aiModels/sambanova.ts

+195
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,195 @@
1+
import { AIChatModelCard } from '@/types/aiModel';
2+
3+
const sambanovaChatModels: AIChatModelCard[] = [
4+
{
5+
abilities: {
6+
functionCall: true,
7+
},
8+
contextWindowTokens: 16_000,
9+
description: 'Llama 3.3 是 Llama 系列最先进的多语言开源大型语言模型,以极低成本体验媲美 405B 模型的性能。基于 Transformer 结构,并通过监督微调(SFT)和人类反馈强化学习(RLHF)提升有用性和安全性。其指令调优版本专为多语言对话优化,在多项行业基准上表现优于众多开源和封闭聊天模型。知识截止日期为 2023 年 12 月',
10+
displayName: 'Meta Llama 3.3 70B Instruct',
11+
enabled: true,
12+
id: 'Meta-Llama-3.3-70B-Instruct',
13+
pricing: {
14+
input: 0.6,
15+
output: 1.2
16+
},
17+
type: 'chat'
18+
},
19+
{
20+
contextWindowTokens: 16_000,
21+
description: '先进的最尖端小型语言模型,具备语言理解、卓越的推理能力和文本生成能力。',
22+
displayName: 'Meta Llama 3.2 1B Instruct',
23+
id: 'Meta-Llama-3.2-1B-Instruct',
24+
pricing: {
25+
input: 0.04,
26+
output: 0.08
27+
},
28+
type: 'chat'
29+
},
30+
{
31+
contextWindowTokens: 8000,
32+
description: '先进的最尖端小型语言模型,具备语言理解、卓越的推理能力和文本生成能力。',
33+
displayName: 'Meta Llama 3.2 3B Instruct',
34+
id: 'Meta-Llama-3.2-3B-Instruct',
35+
pricing: {
36+
input: 0.08,
37+
output: 0.16
38+
},
39+
type: 'chat'
40+
},
41+
{
42+
abilities: {
43+
vision: true,
44+
},
45+
contextWindowTokens: 4000,
46+
description: '在高分辨率图像上表现出色的图像推理能力,适用于视觉理解应用。',
47+
displayName: 'Meta Llama 3.2 11B Vision Instruct',
48+
enabled: true,
49+
id: 'Llama-3.2-11B-Vision-Instruct',
50+
pricing: {
51+
input: 0.15,
52+
output: 0.3
53+
},
54+
type: 'chat'
55+
},
56+
{
57+
abilities: {
58+
vision: true,
59+
},
60+
contextWindowTokens: 4000,
61+
description: '适用于视觉理解代理应用的高级图像推理能力。',
62+
displayName: 'Meta Llama 3.2 90B Vision Instruct',
63+
enabled: true,
64+
id: 'Llama-3.2-90B-Vision-Instruct ',
65+
pricing: {
66+
input: 0.8,
67+
output: 1.6
68+
},
69+
type: 'chat'
70+
},
71+
{
72+
abilities: {
73+
functionCall: true,
74+
},
75+
contextWindowTokens: 16_000,
76+
description: 'Llama 3.1指令调优的文本模型,针对多语言对话用例进行了优化,在许多可用的开源和封闭聊天模型中,在常见行业基准上表现优异。',
77+
displayName: 'Meta Llama 3.1 8B Instruct',
78+
id: 'Meta-Llama-3.1-8B-Instruct',
79+
pricing: {
80+
input: 0.1,
81+
output: 0.2
82+
},
83+
type: 'chat'
84+
},
85+
{
86+
abilities: {
87+
functionCall: true,
88+
},
89+
contextWindowTokens: 128_000,
90+
description: 'Llama 3.1指令调优的文本模型,针对多语言对话用例进行了优化,在许多可用的开源和封闭聊天模型中,在常见行业基准上表现优异。',
91+
displayName: 'Meta Llama 3.1 70B Instruct',
92+
id: 'Meta-Llama-3.1-70B-Instruct',
93+
pricing: {
94+
input: 0.6,
95+
output: 1.2
96+
},
97+
type: 'chat'
98+
},
99+
{
100+
abilities: {
101+
functionCall: true,
102+
},
103+
contextWindowTokens: 16_000,
104+
description: 'Llama 3.1指令调优的文本模型,针对多语言对话用例进行了优化,在许多可用的开源和封闭聊天模型中,在常见行业基准上表现优异。',
105+
displayName: 'Meta Llama 3.1 405B Instruct',
106+
id: 'Meta-Llama-3.1-405B-Instruct',
107+
pricing: {
108+
input: 5,
109+
output: 10
110+
},
111+
type: 'chat'
112+
},
113+
{
114+
contextWindowTokens: 16_000,
115+
displayName: 'Llama 3.1 Tulu 3 405B',
116+
id: 'Llama-3.1-Tulu-3-405B',
117+
pricing: {
118+
input: 0.7,
119+
output: 1.4
120+
},
121+
type: 'chat'
122+
},
123+
{
124+
abilities: {
125+
reasoning: true,
126+
},
127+
contextWindowTokens: 4000,
128+
description: '最先进的高效 LLM,擅长推理、数学和编程。',
129+
displayName: 'DeepSeek R1',
130+
id: 'DeepSeek-R1',
131+
pricing: {
132+
input: 5,
133+
output: 7
134+
},
135+
type: 'chat'
136+
},
137+
{
138+
abilities: {
139+
reasoning: true,
140+
},
141+
contextWindowTokens: 32_000,
142+
description: 'DeepSeek R1——DeepSeek 套件中更大更智能的模型——被蒸馏到 Llama 70B 架构中。基于基准测试和人工评估,该模型比原始 Llama 70B 更智能,尤其在需要数学和事实精确性的任务上表现出色。',
143+
displayName: 'DeepSeek R1 Distill Llama 70B',
144+
enabled: true,
145+
id: 'DeepSeek-R1-Distill-Llama-70B',
146+
pricing: {
147+
input: 0.7,
148+
output: 1.4
149+
},
150+
type: 'chat'
151+
},
152+
{
153+
abilities: {
154+
reasoning: true,
155+
},
156+
contextWindowTokens: 16_000,
157+
description: 'Qwen QwQ 是由 Qwen 团队开发的实验研究模型,专注于提升AI推理能力。',
158+
displayName: 'QwQ 32B Preview',
159+
enabled: true,
160+
id: 'QwQ-32B-Preview',
161+
pricing: {
162+
input: 1.5,
163+
output: 3
164+
},
165+
type: 'chat'
166+
},
167+
{
168+
contextWindowTokens: 16_000,
169+
description: '面向中文和英文的 LLM,针对语言、编程、数学、推理等领域。',
170+
displayName: 'Qwen2.5 72B Instruct',
171+
enabled: true,
172+
id: 'Qwen2.5-72B-Instruct',
173+
pricing: {
174+
input: 2,
175+
output: 4
176+
},
177+
type: 'chat'
178+
},
179+
{
180+
contextWindowTokens: 16_000,
181+
description: '高级 LLM,支持代码生成、推理和修复,涵盖主流编程语言。',
182+
displayName: 'Qwen2.5 Coder 32B Instruct',
183+
enabled: true,
184+
id: 'Qwen2.5-Coder-32B-Instruct',
185+
pricing: {
186+
input: 1.5,
187+
output: 3
188+
},
189+
type: 'chat'
190+
},
191+
]
192+
193+
export const allModels = [...sambanovaChatModels];
194+
195+
export default allModels;

src/config/llm.ts

+6
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ export const getLLMConfig = () => {
140140

141141
ENABLED_JINA: z.boolean(),
142142
JINA_API_KEY: z.string().optional(),
143+
144+
ENABLED_SAMBANOVA: z.boolean(),
145+
SAMBANOVA_API_KEY: z.string().optional(),
143146
},
144147
runtimeEnv: {
145148
API_KEY_SELECT_MODE: process.env.API_KEY_SELECT_MODE,
@@ -278,6 +281,9 @@ export const getLLMConfig = () => {
278281

279282
ENABLED_JINA: !!process.env.JINA_API_KEY,
280283
JINA_API_KEY: process.env.JINA_API_KEY,
284+
285+
ENABLED_SAMBANOVA: !!process.env.SAMBANOVA_API_KEY,
286+
SAMBANOVA_API_KEY: process.env.SAMBANOVA_API_KEY,
281287
},
282288
});
283289
};

src/config/modelProviders/index.ts

+4
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import OpenAIProvider from './openai';
3131
import OpenRouterProvider from './openrouter';
3232
import PerplexityProvider from './perplexity';
3333
import QwenProvider from './qwen';
34+
import SambaNovaProvider from './sambanova';
3435
import SenseNovaProvider from './sensenova';
3536
import SiliconCloudProvider from './siliconcloud';
3637
import SparkProvider from './spark';
@@ -71,6 +72,7 @@ export const LOBE_DEFAULT_MODEL_LIST: ChatModelCard[] = [
7172
HuggingFaceProvider.chatModels,
7273
XAIProvider.chatModels,
7374
JinaProvider.chatModels,
75+
SambaNovaProvider.chatModels,
7476
ZeroOneProvider.chatModels,
7577
StepfunProvider.chatModels,
7678
NovitaProvider.chatModels,
@@ -116,6 +118,7 @@ export const DEFAULT_MODEL_PROVIDER_LIST = [
116118
UpstageProvider,
117119
XAIProvider,
118120
JinaProvider,
121+
SambaNovaProvider,
119122
QwenProvider,
120123
WenxinProvider,
121124
TencentcloudProvider,
@@ -179,6 +182,7 @@ export { default as OpenAIProviderCard } from './openai';
179182
export { default as OpenRouterProviderCard } from './openrouter';
180183
export { default as PerplexityProviderCard } from './perplexity';
181184
export { default as QwenProviderCard } from './qwen';
185+
export { default as SambaNovaProviderCard } from './sambanova';
182186
export { default as SenseNovaProviderCard } from './sensenova';
183187
export { default as SiliconCloudProviderCard } from './siliconcloud';
184188
export { default as SparkProviderCard } from './spark';
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { ModelProviderCard } from '@/types/llm';
2+
3+
const SambaNova: ModelProviderCard = {
4+
chatModels: [],
5+
checkModel: 'Meta-Llama-3.2-1B-Instruct',
6+
description: 'SambaNova Cloud 可让开发者轻松使用最佳的开源模型,并享受最快的推理速度。',
7+
disableBrowserRequest: true,
8+
id: 'sambanova',
9+
modelsUrl: 'https://cloud.sambanova.ai/plans/pricing',
10+
name: 'SambaNova',
11+
settings: {
12+
disableBrowserRequest: true,
13+
sdkType: 'openai',
14+
},
15+
url: 'https://cloud.sambanova.ai',
16+
};
17+
18+
export default SambaNova;

src/libs/agent-runtime/AgentRuntime.ts

+7
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import { LobeOpenAI } from './openai';
3333
import { LobeOpenRouterAI } from './openrouter';
3434
import { LobePerplexityAI } from './perplexity';
3535
import { LobeQwenAI } from './qwen';
36+
import { LobeSambaNovaAI } from './sambanova';
3637
import { LobeSenseNovaAI } from './sensenova';
3738
import { LobeSiliconCloudAI } from './siliconcloud';
3839
import { LobeSparkAI } from './spark';
@@ -169,6 +170,7 @@ class AgentRuntime {
169170
openrouter: Partial<ClientOptions>;
170171
perplexity: Partial<ClientOptions>;
171172
qwen: Partial<ClientOptions>;
173+
sambanova: Partial<ClientOptions>;
172174
sensenova: Partial<ClientOptions>;
173175
siliconcloud: Partial<ClientOptions>;
174176
spark: Partial<ClientOptions>;
@@ -384,6 +386,11 @@ class AgentRuntime {
384386
break;
385387
}
386388

389+
case ModelProvider.SambaNova: {
390+
runtimeModel = new LobeSambaNovaAI(params.sambanova);
391+
break;
392+
}
393+
387394
case ModelProvider.Cloudflare: {
388395
runtimeModel = new LobeCloudflareAI(params.cloudflare);
389396
break;
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { ModelProvider } from '../types';
2+
import { LobeOpenAICompatibleFactory } from '../utils/openaiCompatibleFactory';
3+
4+
export const LobeSambaNovaAI = LobeOpenAICompatibleFactory({
5+
baseURL: 'https://api.sambanova.ai/v1',
6+
debug: {
7+
chatCompletion: () => process.env.DEBUG_SAMBANOVA_CHAT_COMPLETION === '1',
8+
},
9+
provider: ModelProvider.SambaNova,
10+
});

src/libs/agent-runtime/types/type.ts

+1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ export enum ModelProvider {
5656
OpenRouter = 'openrouter',
5757
Perplexity = 'perplexity',
5858
Qwen = 'qwen',
59+
SambaNova = 'sambanova',
5960
SenseNova = 'sensenova',
6061
SiliconCloud = 'siliconcloud',
6162
Spark = 'spark',

src/types/user/settings/keyVaults.ts

+1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ export interface UserKeyVaults {
5959
password?: string;
6060
perplexity?: OpenAICompatibleKeyVault;
6161
qwen?: OpenAICompatibleKeyVault;
62+
sambanova?: OpenAICompatibleKeyVault;
6263
sensenova?: OpenAICompatibleKeyVault;
6364
siliconcloud?: OpenAICompatibleKeyVault;
6465
spark?: OpenAICompatibleKeyVault;

0 commit comments

Comments
 (0)