Skip to content

Commit 0781dc5

Browse files
authored
✨ feat: Add SiliconCloud model provider (#3092)
* feat: Add SiliconCloud as a model provider * model icon * Update index.ts * Update siliconcloud.ts * Update .env.example * Add docs * Update siliconcloud.ts * Update siliconcloud.ts * Update siliconcloud.ts * Update siliconcloud.ts
1 parent a5ac990 commit 0781dc5

File tree

16 files changed

+279
-2
lines changed

16 files changed

+279
-2
lines changed

.env.example

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,10 @@ OPENAI_API_KEY=sk-xxxxxxxxx
112112

113113
# QWEN_API_KEY=sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
114114

115+
### SiliconCloud AI ####
116+
117+
# SILICONCLOUD_API_KEY=sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
118+
115119
########################################
116120
############ Market Service ############
117121
########################################

docs/usage/providers/siliconcloud.mdx

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
title: Using SiliconCloud API Key in LobeChat
3+
description: Learn how to configure and use SiliconCloud's large language models in LobeChat, get your API key, and start chatting.
4+
tags:
5+
- LobeChat
6+
- SiliconCloud
7+
- API Key
8+
- Web UI
9+
---
10+
11+
# Using SiliconCloud in LobeChat
12+
13+
14+
[SiliconCloud](https://siliconflow.cn/zh-cn/siliconcloud) is a cost-effective large model service provider, offering various services such as text generation and image generation.
15+
16+
This document will guide you on how to use SiliconCloud in LobeChat:
17+
18+
<Steps>
19+
20+
### Step 1: Get your SiliconCloud API Key
21+
22+
- First, you need to register and log in to [SiliconCloud](https://cloud.siliconflow.cn/auth/login)
23+
24+
<Callout type={'info'}>Currently, new users can get 14 yuan free credit upon registration</Callout>
25+
26+
- Go to the `API Key` menu and click `Create New API Key`
27+
28+
- Click copy API key and keep it safe
29+
30+
### Step 2: Configure SiliconCloud in LobeChat
31+
32+
- Visit the `App Settings` interface of LobeChat
33+
34+
- Under `Language Model`, find the `SiliconCloud` settings
35+
36+
- Enable SiliconCloud and enter the obtained API key
37+
38+
- Choose a SiliconCloud model for your assistant and start chatting
39+
40+
<Callout type={'warning'}>
41+
You may need to pay the API service provider during use. Please refer to SiliconCloud's relevant fee policy.
42+
</Callout>
43+
44+
</Steps>
45+
46+
Now you can use the models provided by SiliconCloud for conversation in LobeChat.
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
title: 在 LobeChat 中使用 SiliconCloud API Key
3+
description: 学习如何在 LobeChat 中配置和使用 SiliconCloud 提供的大语言模型,获取 API 密钥并开始对话。
4+
tags:
5+
- LobeChat
6+
- SiliconCloud
7+
- API密钥
8+
- Web UI
9+
---
10+
11+
# 在 LobeChat 中使用 SiliconCloud
12+
13+
14+
[SiliconCloud](https://siliconflow.cn/zh-cn/siliconcloud) 是高性价比的大模型服务提供商,提供文本生成与图片生成等多种服务。
15+
16+
本文档将指导你如何在 LobeChat 中使用 SiliconCloud:
17+
18+
<Steps>
19+
20+
### 步骤一:获取 SiliconCloud API 密钥
21+
22+
- 首先,你需要注册并登录 [SiliconCloud](https://cloud.siliconflow.cn/auth/login)
23+
24+
<Callout type={'info'}>当前新用户注册可获赠 14 元免费额度</Callout>
25+
26+
- 进入 `API密钥` 菜单,并点击 `创建新API密钥`
27+
28+
- 点击复制 API 密钥并妥善保存
29+
30+
### 步骤二:在 LobeChat 中配置 SiliconCloud
31+
32+
- 访问 LobeChat 的 `应用设置` 界面
33+
34+
-`语言模型` 下找到 `SiliconCloud` 的设置项
35+
36+
- 打开 SiliconCloud 并填入获取的 API 密钥
37+
38+
- 为你的助手选择一个 SiliconCloud 模型即可开始对话
39+
40+
<Callout type={'warning'}>
41+
在使用过程中你可能需要向 API 服务提供商付费,请参考 SiliconCloud 的相关费用政策。
42+
</Callout>
43+
44+
</Steps>
45+
46+
至此你已经可以在 LobeChat 中使用 SiliconCloud 提供的模型进行对话了。

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
Novita,
1515
OpenRouter,
1616
Perplexity,
17+
SiliconCloud,
1718
Stepfun,
1819
Together,
1920
Tongyi,
@@ -40,6 +41,7 @@ import {
4041
OpenRouterProviderCard,
4142
PerplexityProviderCard,
4243
QwenProviderCard,
44+
SiliconCloudProviderCard,
4345
StepfunProviderCard,
4446
TaichuProviderCard,
4547
TogetherAIProviderCard,
@@ -198,6 +200,11 @@ export const useProviderList = (): ProviderItem[] => {
198200
docUrl: urlJoin(BASE_DOC_URL, 'ai360'),
199201
title: <Ai360.Combine size={ 20 } type={ 'color' } />,
200202
},
203+
{
204+
...SiliconCloudProviderCard,
205+
docUrl: urlJoin(BASE_DOC_URL, 'siliconcloud'),
206+
title: <SiliconCloud.Combine size={20} type={'color'} />,
207+
},
201208
],
202209
[azureProvider, ollamaProvider, ollamaProvider, bedrockProvider],
203210
);

src/app/api/chat/agentRuntime.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,13 @@ const getLlmOptionsFromPayload = (provider: string, payload: JWTPayload) => {
198198

199199
const apiKey = apiKeyManager.pick(payload?.apiKey || AI360_API_KEY);
200200

201+
return { apiKey };
202+
}
203+
case ModelProvider.SiliconCloud: {
204+
const { SILICONCLOUD_API_KEY } = getLLMConfig();
205+
206+
const apiKey = apiKeyManager.pick(payload?.apiKey || SILICONCLOUD_API_KEY);
207+
201208
return { apiKey };
202209
}
203210
}

src/components/ModelIcon/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const ModelIcon = memo<ModelProviderIconProps>(({ model: originModel, size = 12
5151
// currently supported models, maybe not in its own provider
5252
if (model.includes('gpt-3')) return <OpenAI.Avatar size={size} type={'gpt3'} />;
5353
if (model.includes('gpt-4')) return <OpenAI.Avatar size={size} type={'gpt4'} />;
54-
if (model.startsWith('glm') || model.includes('chatglm')) return <ChatGLM.Avatar size={size} />;
54+
if (model.includes('glm-') || model.includes('chatglm')) return <ChatGLM.Avatar size={size} />;
5555
if (model.startsWith('codegeex')) return <CodeGeeX.Avatar size={size} />;
5656
if (model.includes('deepseek')) return <DeepSeek.Avatar size={size} />;
5757
if (model.includes('claude')) return <Claude.Avatar size={size} />;

src/components/ModelProviderIcon/index.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
OpenAI,
1818
OpenRouter,
1919
Perplexity,
20+
SiliconCloud,
2021
Stepfun,
2122
Together,
2223
Tongyi,
@@ -134,6 +135,10 @@ const ModelProviderIcon = memo<ModelProviderIconProps>(({ provider }) => {
134135
return <Ai360 size={20} />;
135136
}
136137

138+
case ModelProvider.SiliconCloud: {
139+
return <SiliconCloud size={20} />;
140+
}
141+
137142
default: {
138143
return null;
139144
}

src/config/llm.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ export const getLLMConfig = () => {
8787

8888
ENABLED_AI360: z.boolean(),
8989
AI360_API_KEY: z.string().optional(),
90+
91+
ENABLED_SILICONCLOUD: z.boolean(),
92+
SILICONCLOUD_API_KEY: z.string().optional(),
9093
},
9194
runtimeEnv: {
9295
API_KEY_SELECT_MODE: process.env.API_KEY_SELECT_MODE,
@@ -171,6 +174,9 @@ export const getLLMConfig = () => {
171174

172175
ENABLED_AI360: !!process.env.AI360_API_KEY,
173176
AI360_API_KEY: process.env.AI360_API_KEY,
177+
178+
ENABLED_SILICONCLOUD: !!process.env.SILICONCLOUD_API_KEY,
179+
SILICONCLOUD_API_KEY: process.env.SILICONCLOUD_API_KEY,
174180
},
175181
});
176182
};

src/config/modelProviders/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import OpenAIProvider from './openai';
1717
import OpenRouterProvider from './openrouter';
1818
import PerplexityProvider from './perplexity';
1919
import QwenProvider from './qwen';
20+
import SiliconCloudProvider from './siliconcloud';
2021
import StepfunProvider from './stepfun';
2122
import TaichuProvider from './taichu';
2223
import TogetherAIProvider from './togetherai';
@@ -45,6 +46,7 @@ export const LOBE_DEFAULT_MODEL_LIST: ChatModelCard[] = [
4546
BaichuanProvider.chatModels,
4647
TaichuProvider.chatModels,
4748
Ai360Provider.chatModels,
49+
SiliconCloudProvider.chatModels,
4850
].flat();
4951

5052
export const DEFAULT_MODEL_PROVIDER_LIST = [
@@ -70,6 +72,7 @@ export const DEFAULT_MODEL_PROVIDER_LIST = [
7072
BaichuanProvider,
7173
TaichuProvider,
7274
Ai360Provider,
75+
SiliconCloudProvider,
7376
];
7477

7578
export const filterEnabledModels = (provider: ModelProviderCard) => {
@@ -98,6 +101,7 @@ export { default as OpenAIProviderCard } from './openai';
98101
export { default as OpenRouterProviderCard } from './openrouter';
99102
export { default as PerplexityProviderCard } from './perplexity';
100103
export { default as QwenProviderCard } from './qwen';
104+
export { default as SiliconCloudProviderCard } from './siliconcloud';
101105
export { default as StepfunProviderCard } from './stepfun';
102106
export { default as TaichuProviderCard } from './taichu';
103107
export { default as TogetherAIProviderCard } from './togetherai';
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
import { ModelProviderCard } from '@/types/llm';
2+
3+
// ref https://siliconflow.cn/zh-cn/models
4+
const SiliconCloud: ModelProviderCard = {
5+
chatModels: [
6+
{
7+
enabled: true,
8+
id: 'Qwen/Qwen2-72B-Instruct',
9+
tokens: 32_768,
10+
},
11+
{
12+
enabled: true,
13+
id: 'Qwen/Qwen2-Math-72B-Instruct',
14+
tokens: 32_768,
15+
},
16+
{
17+
enabled: true,
18+
id: 'Qwen/Qwen2-57B-A14B-Instruct',
19+
tokens: 32_768,
20+
},
21+
{
22+
id: 'Qwen/Qwen2-7B-Instruct',
23+
tokens: 32_768,
24+
},
25+
{
26+
id: 'Qwen/Qwen2-1.5B-Instruct',
27+
tokens: 32_768,
28+
},
29+
{
30+
id: 'Qwen/Qwen1.5-110B-Chat',
31+
tokens: 32_768,
32+
},
33+
{
34+
id: 'Qwen/Qwen1.5-32B-Chat',
35+
tokens: 32_768,
36+
},
37+
{
38+
id: 'Qwen/Qwen1.5-14B-Chat',
39+
tokens: 32_768,
40+
},
41+
{
42+
id: 'Qwen/Qwen1.5-7B-Chat',
43+
tokens: 32_768,
44+
},
45+
{
46+
id: 'deepseek-ai/DeepSeek-Coder-V2-Instruct',
47+
tokens: 32_768,
48+
},
49+
{
50+
enabled: true,
51+
id: 'deepseek-ai/DeepSeek-V2-Chat',
52+
tokens: 32_768,
53+
},
54+
{
55+
id: 'deepseek-ai/deepseek-llm-67b-chat',
56+
tokens: 32_768,
57+
},
58+
{
59+
id: 'THUDM/glm-4-9b-chat',
60+
tokens: 32_768,
61+
},
62+
{
63+
id: 'THUDM/chatglm3-6b',
64+
tokens: 32_768,
65+
},
66+
{
67+
enabled: true,
68+
id: '01-ai/Yi-1.5-34B-Chat-16K',
69+
tokens: 16_384,
70+
},
71+
{
72+
id: '01-ai/Yi-1.5-9B-Chat-16K',
73+
tokens: 16_384,
74+
},
75+
{
76+
id: '01-ai/Yi-1.5-6B-Chat',
77+
tokens: 4096,
78+
},
79+
{
80+
id: 'internlm/internlm2_5-7b-chat',
81+
tokens: 32_768,
82+
},
83+
{
84+
id: 'google/gemma-2-9b-it',
85+
tokens: 8192,
86+
},
87+
{
88+
id: 'google/gemma-2-27b-it',
89+
tokens: 8192,
90+
},
91+
{
92+
id: 'internlm/internlm2_5-20b-chat',
93+
tokens: 32_768,
94+
},
95+
{
96+
id: 'meta-llama/Meta-Llama-3.1-8B-Instruct',
97+
tokens: 32_768,
98+
},
99+
{
100+
enabled: true,
101+
id: 'meta-llama/Meta-Llama-3.1-70B-Instruct',
102+
tokens: 32_768,
103+
},
104+
{
105+
id: 'meta-llama/Meta-Llama-3.1-405B-Instruct',
106+
tokens: 32_768,
107+
},
108+
{
109+
id: 'meta-llama/Meta-Llama-3-70B-Instruct',
110+
tokens: 8192,
111+
},
112+
{
113+
id: 'mistralai/Mistral-7B-Instruct-v0.2',
114+
tokens: 32_768,
115+
},
116+
{
117+
id: 'mistralai/Mixtral-8x7B-Instruct-v0.1',
118+
tokens: 32_768,
119+
},
120+
],
121+
checkModel: 'Qwen/Qwen2-1.5B-Instruct',
122+
id: 'siliconcloud',
123+
modelList: { showModelFetcher: true },
124+
name: 'SiliconCloud',
125+
};
126+
127+
export default SiliconCloud;

0 commit comments

Comments
 (0)