@lobehub/chat 1.33.2 → 1.33.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +50 -0
- package/package.json +1 -1
- package/src/server/modules/AgentRuntime/index.ts +21 -219
- package/src/services/chat.ts +0 -26
package/CHANGELOG.md
CHANGED
@@ -2,6 +2,56 @@
|
|
2
2
|
|
3
3
|
# Changelog
|
4
4
|
|
5
|
+
### [Version 1.33.4](https://github.com/lobehub/lobe-chat/compare/v1.33.3...v1.33.4)
|
6
|
+
|
7
|
+
<sup>Released on **2024-11-26**</sup>
|
8
|
+
|
9
|
+
#### ♻ Code Refactoring
|
10
|
+
|
11
|
+
- **misc**: Refactor `getLlmOptionsFromPayload` from AgentRuntime.
|
12
|
+
|
13
|
+
<br/>
|
14
|
+
|
15
|
+
<details>
|
16
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
17
|
+
|
18
|
+
#### Code refactoring
|
19
|
+
|
20
|
+
- **misc**: Refactor `getLlmOptionsFromPayload` from AgentRuntime, closes [#4790](https://github.com/lobehub/lobe-chat/issues/4790) ([e8948e6](https://github.com/lobehub/lobe-chat/commit/e8948e6))
|
21
|
+
|
22
|
+
</details>
|
23
|
+
|
24
|
+
<div align="right">
|
25
|
+
|
26
|
+
[](#readme-top)
|
27
|
+
|
28
|
+
</div>
|
29
|
+
|
30
|
+
### [Version 1.33.3](https://github.com/lobehub/lobe-chat/compare/v1.33.2...v1.33.3)
|
31
|
+
|
32
|
+
<sup>Released on **2024-11-25**</sup>
|
33
|
+
|
34
|
+
#### 🐛 Bug Fixes
|
35
|
+
|
36
|
+
- **misc**: Fix `fetchOnClient` functional for Moonshot.
|
37
|
+
|
38
|
+
<br/>
|
39
|
+
|
40
|
+
<details>
|
41
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
42
|
+
|
43
|
+
#### What's fixed
|
44
|
+
|
45
|
+
- **misc**: Fix `fetchOnClient` functional for Moonshot, closes [#4787](https://github.com/lobehub/lobe-chat/issues/4787) ([bef89a7](https://github.com/lobehub/lobe-chat/commit/bef89a7))
|
46
|
+
|
47
|
+
</details>
|
48
|
+
|
49
|
+
<div align="right">
|
50
|
+
|
51
|
+
[](#readme-top)
|
52
|
+
|
53
|
+
</div>
|
54
|
+
|
5
55
|
### [Version 1.33.2](https://github.com/lobehub/lobe-chat/compare/v1.33.1...v1.33.2)
|
6
56
|
|
7
57
|
<sup>Released on **2024-11-25**</sup>
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@lobehub/chat",
|
3
|
-
"version": "1.33.
|
3
|
+
"version": "1.33.4",
|
4
4
|
"description": "Lobe Chat - an open-source, high-performance chatbot framework that supports speech synthesis, multimodal, and extensible Function Call plugin system. Supports one-click free deployment of your private ChatGPT/LLM web application.",
|
5
5
|
"keywords": [
|
6
6
|
"framework",
|
@@ -27,54 +27,32 @@ export interface AgentChatOptions {
|
|
27
27
|
* @returns The options object.
|
28
28
|
*/
|
29
29
|
const getLlmOptionsFromPayload = (provider: string, payload: JWTPayload) => {
|
30
|
+
const llmConfig = getLLMConfig() as Record<string, any>;
|
31
|
+
|
30
32
|
switch (provider) {
|
31
|
-
default:
|
32
|
-
|
33
|
-
|
33
|
+
default: {
|
34
|
+
let upperProvider = provider.toUpperCase();
|
35
|
+
|
36
|
+
if (!llmConfig[`${upperProvider}_API_KEY`]) {
|
37
|
+
upperProvider = ModelProvider.OpenAI.toUpperCase(); // Use OpenAI options as default
|
38
|
+
}
|
34
39
|
|
35
|
-
const
|
36
|
-
const baseURL = payload?.endpoint || process.env
|
37
|
-
const apiKey = apiKeyManager.pick(openaiApiKey);
|
40
|
+
const apiKey = apiKeyManager.pick(payload?.apiKey || llmConfig[`${upperProvider}_API_KEY`]);
|
41
|
+
const baseURL = payload?.endpoint || process.env[`${upperProvider}_PROXY_URL`];
|
38
42
|
|
39
43
|
return { apiKey, baseURL };
|
40
44
|
}
|
45
|
+
|
41
46
|
case ModelProvider.Azure: {
|
42
|
-
const { AZURE_API_KEY, AZURE_API_VERSION, AZURE_ENDPOINT } =
|
43
|
-
const
|
47
|
+
const { AZURE_API_KEY, AZURE_API_VERSION, AZURE_ENDPOINT } = llmConfig;
|
48
|
+
const apikey = apiKeyManager.pick(payload?.apiKey || AZURE_API_KEY);
|
44
49
|
const endpoint = payload?.endpoint || AZURE_ENDPOINT;
|
45
50
|
const apiVersion = payload?.azureApiVersion || AZURE_API_VERSION;
|
46
|
-
return {
|
47
|
-
apiVersion,
|
48
|
-
apikey: apiKey,
|
49
|
-
endpoint,
|
50
|
-
};
|
51
|
-
}
|
52
|
-
case ModelProvider.ZhiPu: {
|
53
|
-
const { ZHIPU_API_KEY } = getLLMConfig();
|
54
|
-
|
55
|
-
const apiKey = apiKeyManager.pick(payload?.apiKey || ZHIPU_API_KEY);
|
56
|
-
|
57
|
-
return { apiKey };
|
51
|
+
return { apiVersion, apikey, endpoint };
|
58
52
|
}
|
59
|
-
case ModelProvider.Google: {
|
60
|
-
const { GOOGLE_API_KEY } = getLLMConfig();
|
61
53
|
|
62
|
-
const apiKey = apiKeyManager.pick(payload?.apiKey || GOOGLE_API_KEY);
|
63
|
-
const baseURL = payload?.endpoint || process.env.GOOGLE_PROXY_URL;
|
64
|
-
|
65
|
-
return { apiKey, baseURL };
|
66
|
-
}
|
67
|
-
case ModelProvider.Moonshot: {
|
68
|
-
const { MOONSHOT_API_KEY } = getLLMConfig();
|
69
|
-
|
70
|
-
const apiKey = apiKeyManager.pick(payload?.apiKey || MOONSHOT_API_KEY);
|
71
|
-
const baseURL = payload?.endpoint || process.env.MOONSHOT_PROXY_URL;
|
72
|
-
|
73
|
-
return { apiKey, baseURL };
|
74
|
-
}
|
75
54
|
case ModelProvider.Bedrock: {
|
76
|
-
const { AWS_SECRET_ACCESS_KEY, AWS_ACCESS_KEY_ID, AWS_REGION, AWS_SESSION_TOKEN } =
|
77
|
-
getLLMConfig();
|
55
|
+
const { AWS_SECRET_ACCESS_KEY, AWS_ACCESS_KEY_ID, AWS_REGION, AWS_SESSION_TOKEN } = llmConfig;
|
78
56
|
let accessKeyId: string | undefined = AWS_ACCESS_KEY_ID;
|
79
57
|
let accessKeySecret: string | undefined = AWS_SECRET_ACCESS_KEY;
|
80
58
|
let region = AWS_REGION;
|
@@ -88,127 +66,9 @@ const getLlmOptionsFromPayload = (provider: string, payload: JWTPayload) => {
|
|
88
66
|
}
|
89
67
|
return { accessKeyId, accessKeySecret, region, sessionToken };
|
90
68
|
}
|
91
|
-
case ModelProvider.Ollama: {
|
92
|
-
const baseURL = payload?.endpoint || process.env.OLLAMA_PROXY_URL;
|
93
|
-
return { baseURL };
|
94
|
-
}
|
95
|
-
case ModelProvider.Perplexity: {
|
96
|
-
const { PERPLEXITY_API_KEY } = getLLMConfig();
|
97
|
-
|
98
|
-
const apiKey = apiKeyManager.pick(payload?.apiKey || PERPLEXITY_API_KEY);
|
99
|
-
const baseURL = payload?.endpoint || process.env.PERPLEXITY_PROXY_URL;
|
100
|
-
|
101
|
-
return { apiKey, baseURL };
|
102
|
-
}
|
103
|
-
case ModelProvider.Anthropic: {
|
104
|
-
const { ANTHROPIC_API_KEY } = getLLMConfig();
|
105
|
-
|
106
|
-
const apiKey = apiKeyManager.pick(payload?.apiKey || ANTHROPIC_API_KEY);
|
107
|
-
const baseURL = payload?.endpoint || process.env.ANTHROPIC_PROXY_URL;
|
108
|
-
|
109
|
-
return { apiKey, baseURL };
|
110
|
-
}
|
111
|
-
case ModelProvider.Minimax: {
|
112
|
-
const { MINIMAX_API_KEY } = getLLMConfig();
|
113
|
-
|
114
|
-
const apiKey = apiKeyManager.pick(payload?.apiKey || MINIMAX_API_KEY);
|
115
|
-
|
116
|
-
return { apiKey };
|
117
|
-
}
|
118
|
-
case ModelProvider.Mistral: {
|
119
|
-
const { MISTRAL_API_KEY } = getLLMConfig();
|
120
|
-
|
121
|
-
const apiKey = apiKeyManager.pick(payload?.apiKey || MISTRAL_API_KEY);
|
122
|
-
|
123
|
-
return { apiKey };
|
124
|
-
}
|
125
|
-
case ModelProvider.Groq: {
|
126
|
-
const { GROQ_API_KEY } = getLLMConfig();
|
127
|
-
|
128
|
-
const apiKey = apiKeyManager.pick(payload?.apiKey || GROQ_API_KEY);
|
129
|
-
const baseURL = payload?.endpoint || process.env.GROQ_PROXY_URL;
|
130
|
-
|
131
|
-
return { apiKey, baseURL };
|
132
|
-
}
|
133
|
-
case ModelProvider.Github: {
|
134
|
-
const { GITHUB_TOKEN } = getLLMConfig();
|
135
|
-
|
136
|
-
const apiKey = apiKeyManager.pick(payload?.apiKey || GITHUB_TOKEN);
|
137
|
-
|
138
|
-
return { apiKey };
|
139
|
-
}
|
140
|
-
case ModelProvider.OpenRouter: {
|
141
|
-
const { OPENROUTER_API_KEY } = getLLMConfig();
|
142
|
-
|
143
|
-
const apiKey = apiKeyManager.pick(payload?.apiKey || OPENROUTER_API_KEY);
|
144
|
-
|
145
|
-
return { apiKey };
|
146
|
-
}
|
147
|
-
case ModelProvider.DeepSeek: {
|
148
|
-
const { DEEPSEEK_API_KEY } = getLLMConfig();
|
149
|
-
|
150
|
-
const apiKey = apiKeyManager.pick(payload?.apiKey || DEEPSEEK_API_KEY);
|
151
|
-
|
152
|
-
return { apiKey };
|
153
|
-
}
|
154
|
-
case ModelProvider.TogetherAI: {
|
155
|
-
const { TOGETHERAI_API_KEY } = getLLMConfig();
|
156
|
-
|
157
|
-
const apiKey = apiKeyManager.pick(payload?.apiKey || TOGETHERAI_API_KEY);
|
158
|
-
|
159
|
-
return { apiKey };
|
160
|
-
}
|
161
|
-
case ModelProvider.FireworksAI: {
|
162
|
-
const { FIREWORKSAI_API_KEY } = getLLMConfig();
|
163
|
-
|
164
|
-
const apiKey = apiKeyManager.pick(payload?.apiKey || FIREWORKSAI_API_KEY);
|
165
|
-
|
166
|
-
return { apiKey };
|
167
|
-
}
|
168
|
-
case ModelProvider.ZeroOne: {
|
169
|
-
const { ZEROONE_API_KEY } = getLLMConfig();
|
170
|
-
|
171
|
-
const apiKey = apiKeyManager.pick(payload?.apiKey || ZEROONE_API_KEY);
|
172
|
-
|
173
|
-
return { apiKey };
|
174
|
-
}
|
175
|
-
case ModelProvider.Qwen: {
|
176
|
-
const { QWEN_API_KEY } = getLLMConfig();
|
177
|
-
|
178
|
-
const apiKey = apiKeyManager.pick(payload?.apiKey || QWEN_API_KEY);
|
179
69
|
|
180
|
-
return { apiKey };
|
181
|
-
}
|
182
|
-
case ModelProvider.Stepfun: {
|
183
|
-
const { STEPFUN_API_KEY } = getLLMConfig();
|
184
|
-
|
185
|
-
const apiKey = apiKeyManager.pick(payload?.apiKey || STEPFUN_API_KEY);
|
186
|
-
|
187
|
-
return { apiKey };
|
188
|
-
}
|
189
|
-
case ModelProvider.Novita: {
|
190
|
-
const { NOVITA_API_KEY } = getLLMConfig();
|
191
|
-
|
192
|
-
const apiKey = apiKeyManager.pick(payload?.apiKey || NOVITA_API_KEY);
|
193
|
-
|
194
|
-
return { apiKey };
|
195
|
-
}
|
196
|
-
case ModelProvider.Baichuan: {
|
197
|
-
const { BAICHUAN_API_KEY } = getLLMConfig();
|
198
|
-
|
199
|
-
const apiKey = apiKeyManager.pick(payload?.apiKey || BAICHUAN_API_KEY);
|
200
|
-
|
201
|
-
return { apiKey };
|
202
|
-
}
|
203
|
-
case ModelProvider.Taichu: {
|
204
|
-
const { TAICHU_API_KEY } = getLLMConfig();
|
205
|
-
|
206
|
-
const apiKey = apiKeyManager.pick(payload?.apiKey || TAICHU_API_KEY);
|
207
|
-
|
208
|
-
return { apiKey };
|
209
|
-
}
|
210
70
|
case ModelProvider.Cloudflare: {
|
211
|
-
const { CLOUDFLARE_API_KEY, CLOUDFLARE_BASE_URL_OR_ACCOUNT_ID } =
|
71
|
+
const { CLOUDFLARE_API_KEY, CLOUDFLARE_BASE_URL_OR_ACCOUNT_ID } = llmConfig;
|
212
72
|
|
213
73
|
const apiKey = apiKeyManager.pick(payload?.apiKey || CLOUDFLARE_API_KEY);
|
214
74
|
const baseURLOrAccountID =
|
@@ -218,68 +78,25 @@ const getLlmOptionsFromPayload = (provider: string, payload: JWTPayload) => {
|
|
218
78
|
|
219
79
|
return { apiKey, baseURLOrAccountID };
|
220
80
|
}
|
221
|
-
case ModelProvider.Ai360: {
|
222
|
-
const { AI360_API_KEY } = getLLMConfig();
|
223
|
-
|
224
|
-
const apiKey = apiKeyManager.pick(payload?.apiKey || AI360_API_KEY);
|
225
|
-
|
226
|
-
return { apiKey };
|
227
|
-
}
|
228
|
-
case ModelProvider.SiliconCloud: {
|
229
|
-
const { SILICONCLOUD_API_KEY } = getLLMConfig();
|
230
|
-
|
231
|
-
const apiKey = apiKeyManager.pick(payload?.apiKey || SILICONCLOUD_API_KEY);
|
232
|
-
const baseURL = payload?.endpoint || process.env.SILICONCLOUD_PROXY_URL;
|
233
81
|
|
234
|
-
return { apiKey, baseURL };
|
235
|
-
}
|
236
82
|
case ModelProvider.GiteeAI: {
|
237
|
-
const { GITEE_AI_API_KEY } =
|
83
|
+
const { GITEE_AI_API_KEY } = llmConfig;
|
238
84
|
|
239
85
|
const apiKey = apiKeyManager.pick(payload?.apiKey || GITEE_AI_API_KEY);
|
240
86
|
|
241
87
|
return { apiKey };
|
242
88
|
}
|
243
89
|
|
244
|
-
case ModelProvider.
|
245
|
-
const {
|
246
|
-
|
247
|
-
const apiKey = apiKeyManager.pick(payload?.apiKey || HUGGINGFACE_API_KEY);
|
248
|
-
const baseURL = payload?.endpoint || process.env.HUGGINGFACE_PROXY_URL;
|
249
|
-
|
250
|
-
return { apiKey, baseURL };
|
251
|
-
}
|
252
|
-
|
253
|
-
case ModelProvider.Upstage: {
|
254
|
-
const { UPSTAGE_API_KEY } = getLLMConfig();
|
255
|
-
|
256
|
-
const apiKey = apiKeyManager.pick(payload?.apiKey || UPSTAGE_API_KEY);
|
257
|
-
|
258
|
-
return { apiKey };
|
259
|
-
}
|
260
|
-
case ModelProvider.Spark: {
|
261
|
-
const { SPARK_API_KEY } = getLLMConfig();
|
262
|
-
|
263
|
-
const apiKey = apiKeyManager.pick(payload?.apiKey || SPARK_API_KEY);
|
264
|
-
|
265
|
-
return { apiKey };
|
266
|
-
}
|
267
|
-
case ModelProvider.Ai21: {
|
268
|
-
const { AI21_API_KEY } = getLLMConfig();
|
90
|
+
case ModelProvider.Github: {
|
91
|
+
const { GITHUB_TOKEN } = llmConfig;
|
269
92
|
|
270
|
-
const apiKey = apiKeyManager.pick(payload?.apiKey ||
|
93
|
+
const apiKey = apiKeyManager.pick(payload?.apiKey || GITHUB_TOKEN);
|
271
94
|
|
272
95
|
return { apiKey };
|
273
96
|
}
|
274
|
-
case ModelProvider.Hunyuan: {
|
275
|
-
const { HUNYUAN_API_KEY } = getLLMConfig();
|
276
|
-
|
277
|
-
const apiKey = apiKeyManager.pick(payload?.apiKey || HUNYUAN_API_KEY);
|
278
97
|
|
279
|
-
return { apiKey };
|
280
|
-
}
|
281
98
|
case ModelProvider.SenseNova: {
|
282
|
-
const { SENSENOVA_ACCESS_KEY_ID, SENSENOVA_ACCESS_KEY_SECRET } =
|
99
|
+
const { SENSENOVA_ACCESS_KEY_ID, SENSENOVA_ACCESS_KEY_SECRET } = llmConfig;
|
283
100
|
|
284
101
|
const sensenovaAccessKeyID = apiKeyManager.pick(
|
285
102
|
payload?.sensenovaAccessKeyID || SENSENOVA_ACCESS_KEY_ID,
|
@@ -290,21 +107,6 @@ const getLlmOptionsFromPayload = (provider: string, payload: JWTPayload) => {
|
|
290
107
|
|
291
108
|
const apiKey = sensenovaAccessKeyID + ':' + sensenovaAccessKeySecret;
|
292
109
|
|
293
|
-
return { apiKey };
|
294
|
-
}
|
295
|
-
case ModelProvider.XAI: {
|
296
|
-
const { XAI_API_KEY } = getLLMConfig();
|
297
|
-
|
298
|
-
const apiKey = apiKeyManager.pick(payload?.apiKey || XAI_API_KEY);
|
299
|
-
const baseURL = payload?.endpoint || process.env.XAI_PROXY_URL;
|
300
|
-
|
301
|
-
return { apiKey, baseURL };
|
302
|
-
}
|
303
|
-
case ModelProvider.InternLM: {
|
304
|
-
const { INTERNLM_API_KEY } = getLLMConfig();
|
305
|
-
|
306
|
-
const apiKey = apiKeyManager.pick(payload?.apiKey || INTERNLM_API_KEY);
|
307
|
-
|
308
110
|
return { apiKey };
|
309
111
|
}
|
310
112
|
}
|
package/src/services/chat.ts
CHANGED
@@ -106,18 +106,12 @@ export function initializeWithClientStore(provider: string, payload: any) {
|
|
106
106
|
};
|
107
107
|
break;
|
108
108
|
}
|
109
|
-
case ModelProvider.ZhiPu: {
|
110
|
-
break;
|
111
|
-
}
|
112
109
|
case ModelProvider.Google: {
|
113
110
|
providerOptions = {
|
114
111
|
baseURL: providerAuthPayload?.endpoint,
|
115
112
|
};
|
116
113
|
break;
|
117
114
|
}
|
118
|
-
case ModelProvider.Moonshot: {
|
119
|
-
break;
|
120
|
-
}
|
121
115
|
case ModelProvider.Bedrock: {
|
122
116
|
if (providerAuthPayload?.apiKey) {
|
123
117
|
providerOptions = {
|
@@ -142,20 +136,12 @@ export function initializeWithClientStore(provider: string, payload: any) {
|
|
142
136
|
};
|
143
137
|
break;
|
144
138
|
}
|
145
|
-
case ModelProvider.Qwen: {
|
146
|
-
break;
|
147
|
-
}
|
148
|
-
|
149
139
|
case ModelProvider.Anthropic: {
|
150
140
|
providerOptions = {
|
151
141
|
baseURL: providerAuthPayload?.endpoint,
|
152
142
|
};
|
153
143
|
break;
|
154
144
|
}
|
155
|
-
|
156
|
-
case ModelProvider.Mistral: {
|
157
|
-
break;
|
158
|
-
}
|
159
145
|
case ModelProvider.Groq: {
|
160
146
|
providerOptions = {
|
161
147
|
apikey: providerAuthPayload?.apiKey,
|
@@ -163,18 +149,6 @@ export function initializeWithClientStore(provider: string, payload: any) {
|
|
163
149
|
};
|
164
150
|
break;
|
165
151
|
}
|
166
|
-
case ModelProvider.DeepSeek: {
|
167
|
-
break;
|
168
|
-
}
|
169
|
-
case ModelProvider.OpenRouter: {
|
170
|
-
break;
|
171
|
-
}
|
172
|
-
case ModelProvider.TogetherAI: {
|
173
|
-
break;
|
174
|
-
}
|
175
|
-
case ModelProvider.ZeroOne: {
|
176
|
-
break;
|
177
|
-
}
|
178
152
|
case ModelProvider.Cloudflare: {
|
179
153
|
providerOptions = {
|
180
154
|
apikey: providerAuthPayload?.apiKey,
|