@lobehub/chat 1.16.13 → 1.17.0
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.
Potentially problematic release.
This version of @lobehub/chat might be problematic. Click here for more details.
- package/CHANGELOG.md +58 -0
- package/docs/usage/agents/model.mdx +0 -1
- package/docs/usage/agents/model.zh-CN.mdx +0 -1
- package/package.json +1 -1
- package/src/config/llm.ts +2 -0
- package/src/config/modelProviders/openai.ts +28 -37
- package/src/libs/agent-runtime/openai/__snapshots__/index.test.ts.snap +0 -23
- package/src/libs/agent-runtime/openai/index.ts +27 -1
- package/src/server/globalConfig/index.ts +10 -1
- package/src/server/routers/edge/config/__snapshots__/index.test.ts.snap +0 -12
- package/src/server/routers/edge/config/index.test.ts +1 -1
- package/src/store/user/slices/modelList/selectors/modelProvider.test.ts +8 -1
package/CHANGELOG.md
CHANGED
@@ -2,6 +2,64 @@
|
|
2
2
|
|
3
3
|
# Changelog
|
4
4
|
|
5
|
+
## [Version 1.17.0](https://github.com/lobehub/lobe-chat/compare/v1.16.14...v1.17.0)
|
6
|
+
|
7
|
+
<sup>Released on **2024-09-13**</sup>
|
8
|
+
|
9
|
+
#### ✨ Features
|
10
|
+
|
11
|
+
- **misc**: Support openai new OpenAI o1-preview/o1-mini models.
|
12
|
+
|
13
|
+
#### 💄 Styles
|
14
|
+
|
15
|
+
- **misc**: Support Google Model List.
|
16
|
+
|
17
|
+
<br/>
|
18
|
+
|
19
|
+
<details>
|
20
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
21
|
+
|
22
|
+
#### What's improved
|
23
|
+
|
24
|
+
- **misc**: Support openai new OpenAI o1-preview/o1-mini models, closes [#3943](https://github.com/lobehub/lobe-chat/issues/3943) ([61bfeb2](https://github.com/lobehub/lobe-chat/commit/61bfeb2))
|
25
|
+
|
26
|
+
#### Styles
|
27
|
+
|
28
|
+
- **misc**: Support Google Model List, closes [#3938](https://github.com/lobehub/lobe-chat/issues/3938) ([be4efc7](https://github.com/lobehub/lobe-chat/commit/be4efc7))
|
29
|
+
|
30
|
+
</details>
|
31
|
+
|
32
|
+
<div align="right">
|
33
|
+
|
34
|
+
[](#readme-top)
|
35
|
+
|
36
|
+
</div>
|
37
|
+
|
38
|
+
### [Version 1.16.14](https://github.com/lobehub/lobe-chat/compare/v1.16.13...v1.16.14)
|
39
|
+
|
40
|
+
<sup>Released on **2024-09-13**</sup>
|
41
|
+
|
42
|
+
#### 💄 Styles
|
43
|
+
|
44
|
+
- **model**: Remove `OpenAI` deprecated model.
|
45
|
+
|
46
|
+
<br/>
|
47
|
+
|
48
|
+
<details>
|
49
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
50
|
+
|
51
|
+
#### Styles
|
52
|
+
|
53
|
+
- **model**: Remove `OpenAI` deprecated model, closes [#3465](https://github.com/lobehub/lobe-chat/issues/3465) ([68a4fb2](https://github.com/lobehub/lobe-chat/commit/68a4fb2))
|
54
|
+
|
55
|
+
</details>
|
56
|
+
|
57
|
+
<div align="right">
|
58
|
+
|
59
|
+
[](#readme-top)
|
60
|
+
|
61
|
+
</div>
|
62
|
+
|
5
63
|
### [Version 1.16.13](https://github.com/lobehub/lobe-chat/compare/v1.16.12...v1.16.13)
|
6
64
|
|
7
65
|
<sup>Released on **2024-09-13**</sup>
|
@@ -17,7 +17,6 @@ tags:
|
|
17
17
|
## ChatGPT
|
18
18
|
|
19
19
|
- **gpt-3.5-turbo**: Currently the fastest generating ChatGPT model, it is faster but may sacrifice some text quality, with a context length of 4k.
|
20
|
-
- **gpt-3.5-turbo-16k**: Similar to gpt-4, the context limit is increased to 16k tokens, with a higher cost.
|
21
20
|
- **gpt-4**: ChatGPT 4.0 has improved language understanding and generation capabilities compared to 3.5. It can better understand context and context, and generate more accurate and natural responses. This is thanks to improvements in the GPT-4 model, including better language modeling and deeper semantic understanding, but it may be slower than other models, with a context length of 8k.
|
22
21
|
- **gpt-4-32k**: Similar to gpt-4, the context limit is increased to 32k tokens, with a higher cost.
|
23
22
|
|
@@ -16,7 +16,6 @@ tags:
|
|
16
16
|
## ChatGPT
|
17
17
|
|
18
18
|
- **gpt-3.5-turbo**:目前最生成速度最快的 chatgpt 模型更快,但可能会牺牲一些生成文本的质量,上下文长度为 4k。
|
19
|
-
- **gpt-3.5-turbo-16k**:同 gpt-4,上下文限制增加到 16k token,同时费率更高。
|
20
19
|
- **gpt-4**:ChatGPT 4.0 在语言理解和生成能力方面相对于 3.5 有所提升。它可以更好地理解上下文和语境,并生成更准确、自然的回答。这得益于 GPT-4 模型的改进,包括更好的语言建模和更深入的语义理解,但它的速度可能比其他模型慢,上下文长度为 8k。
|
21
20
|
- **gpt-4-32k**:同 gpt-4,上下文限制增加到 32k token,同时费率更高。
|
22
21
|
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@lobehub/chat",
|
3
|
-
"version": "1.
|
3
|
+
"version": "1.17.0",
|
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",
|
package/src/config/llm.ts
CHANGED
@@ -28,6 +28,7 @@ export const getLLMConfig = () => {
|
|
28
28
|
ENABLED_GOOGLE: z.boolean(),
|
29
29
|
GOOGLE_API_KEY: z.string().optional(),
|
30
30
|
GOOGLE_PROXY_URL: z.string().optional(),
|
31
|
+
GOOGLE_MODEL_LIST: z.string().optional(),
|
31
32
|
|
32
33
|
ENABLED_MOONSHOT: z.boolean(),
|
33
34
|
MOONSHOT_API_KEY: z.string().optional(),
|
@@ -134,6 +135,7 @@ export const getLLMConfig = () => {
|
|
134
135
|
ENABLED_GOOGLE: !!process.env.GOOGLE_API_KEY,
|
135
136
|
GOOGLE_API_KEY: process.env.GOOGLE_API_KEY,
|
136
137
|
GOOGLE_PROXY_URL: process.env.GOOGLE_PROXY_URL,
|
138
|
+
GOOGLE_MODEL_LIST: process.env.GOOGLE_MODEL_LIST,
|
137
139
|
|
138
140
|
ENABLED_PERPLEXITY: !!process.env.PERPLEXITY_API_KEY,
|
139
141
|
PERPLEXITY_API_KEY: process.env.PERPLEXITY_API_KEY,
|
@@ -3,6 +3,34 @@ import { ModelProviderCard } from '@/types/llm';
|
|
3
3
|
// ref: https://platform.openai.com/docs/deprecations
|
4
4
|
const OpenAI: ModelProviderCard = {
|
5
5
|
chatModels: [
|
6
|
+
{
|
7
|
+
description:
|
8
|
+
'o1-mini是一款针对编程、数学和科学应用场景而设计的快速、经济高效的推理模型。该模型具有128K上下文和2023年10月的知识截止日期。',
|
9
|
+
displayName: 'OpenAI o1-mini',
|
10
|
+
enabled: true,
|
11
|
+
id: 'o1-mini',
|
12
|
+
maxOutput: 65_536,
|
13
|
+
pricing: {
|
14
|
+
input: 3,
|
15
|
+
output: 12,
|
16
|
+
},
|
17
|
+
releasedAt: '2024-09-12',
|
18
|
+
tokens: 128_000,
|
19
|
+
},
|
20
|
+
{
|
21
|
+
description:
|
22
|
+
'o1是OpenAI新的推理模型,适用于需要广泛通用知识的复杂任务。该模型具有128K上下文和2023年10月的知识截止日期。',
|
23
|
+
displayName: 'OpenAI o1-preview',
|
24
|
+
enabled: true,
|
25
|
+
id: 'o1-preview',
|
26
|
+
maxOutput: 32_768,
|
27
|
+
pricing: {
|
28
|
+
input: 15,
|
29
|
+
output: 60,
|
30
|
+
},
|
31
|
+
releasedAt: '2024-09-12',
|
32
|
+
tokens: 128_000,
|
33
|
+
},
|
6
34
|
{
|
7
35
|
description:
|
8
36
|
'GPT-4o mini是OpenAI在GPT-4 Omni之后推出的最新模型,支持图文输入并输出文本。作为他们最先进的小型模型,它比其他近期的前沿模型便宜很多,并且比GPT-3.5 Turbo便宜超过60%。它保持了最先进的智能,同时具有显著的性价比。GPT-4o mini在MMLU测试中获得了 82% 的得分,目前在聊天偏好上排名高于 GPT-4。',
|
@@ -253,43 +281,6 @@ const OpenAI: ModelProviderCard = {
|
|
253
281
|
},
|
254
282
|
tokens: 4096,
|
255
283
|
},
|
256
|
-
{
|
257
|
-
description:
|
258
|
-
'GPT 3.5 Turbo,适用于各种文本生成和理解任务,Currently points to gpt-3.5-turbo-0125', // Will be discontinued on September 13, 2024
|
259
|
-
|
260
|
-
displayName: 'GPT-3.5 Turbo 16K',
|
261
|
-
id: 'gpt-3.5-turbo-16k',
|
262
|
-
legacy: true,
|
263
|
-
pricing: {
|
264
|
-
input: 3,
|
265
|
-
output: 4,
|
266
|
-
},
|
267
|
-
tokens: 16_385,
|
268
|
-
},
|
269
|
-
{
|
270
|
-
description:
|
271
|
-
'GPT-3.5 Turbo 是 OpenAI 的一款基础模型,结合了高效性和经济性,广泛用于文本生成、理解和分析,专为指导性提示进行调整,去除了与聊天相关的优化。',
|
272
|
-
displayName: 'GPT-3.5 Turbo 0613',
|
273
|
-
// Will be discontinued on September 13, 2024
|
274
|
-
id: 'gpt-3.5-turbo-0613',
|
275
|
-
legacy: true,
|
276
|
-
pricing: {
|
277
|
-
input: 1.5,
|
278
|
-
output: 2,
|
279
|
-
},
|
280
|
-
tokens: 4096,
|
281
|
-
},
|
282
|
-
{
|
283
|
-
description:
|
284
|
-
'GPT-3.5 Turbo 是 OpenAI 的一款基础模型,结合了高效性和经济性,广泛用于文本生成、理解和分析,专为指导性提示进行调整,去除了与聊天相关的优化。', // Will be discontinued on September 13, 2024
|
285
|
-
id: 'gpt-3.5-turbo-16k-0613',
|
286
|
-
legacy: true,
|
287
|
-
pricing: {
|
288
|
-
input: 3,
|
289
|
-
output: 4,
|
290
|
-
},
|
291
|
-
tokens: 16_385,
|
292
|
-
},
|
293
284
|
],
|
294
285
|
checkModel: 'gpt-4o-mini',
|
295
286
|
description:
|
@@ -14,25 +14,10 @@ exports[`LobeOpenAI > models > should get models 1`] = `
|
|
14
14
|
"tokens": 16385,
|
15
15
|
},
|
16
16
|
{
|
17
|
-
"description": "GPT 3.5 Turbo,适用于各种文本生成和理解任务,Currently points to gpt-3.5-turbo-0125",
|
18
|
-
"displayName": "GPT-3.5 Turbo 16K",
|
19
17
|
"id": "gpt-3.5-turbo-16k",
|
20
|
-
"legacy": true,
|
21
|
-
"pricing": {
|
22
|
-
"input": 3,
|
23
|
-
"output": 4,
|
24
|
-
},
|
25
|
-
"tokens": 16385,
|
26
18
|
},
|
27
19
|
{
|
28
|
-
"description": "GPT-3.5 Turbo 是 OpenAI 的一款基础模型,结合了高效性和经济性,广泛用于文本生成、理解和分析,专为指导性提示进行调整,去除了与聊天相关的优化。",
|
29
20
|
"id": "gpt-3.5-turbo-16k-0613",
|
30
|
-
"legacy": true,
|
31
|
-
"pricing": {
|
32
|
-
"input": 3,
|
33
|
-
"output": 4,
|
34
|
-
},
|
35
|
-
"tokens": 16385,
|
36
21
|
},
|
37
22
|
{
|
38
23
|
"description": "最新的 GPT-4 Turbo 模型具备视觉功能。现在,视觉请求可以使用 JSON 模式和函数调用。 GPT-4 Turbo 是一个增强版本,为多模态任务提供成本效益高的支持。它在准确性和效率之间找到平衡,适合需要进行实时交互的应用程序场景。",
|
@@ -83,15 +68,7 @@ exports[`LobeOpenAI > models > should get models 1`] = `
|
|
83
68
|
"id": "gpt-3.5-turbo-0301",
|
84
69
|
},
|
85
70
|
{
|
86
|
-
"description": "GPT-3.5 Turbo 是 OpenAI 的一款基础模型,结合了高效性和经济性,广泛用于文本生成、理解和分析,专为指导性提示进行调整,去除了与聊天相关的优化。",
|
87
|
-
"displayName": "GPT-3.5 Turbo 0613",
|
88
71
|
"id": "gpt-3.5-turbo-0613",
|
89
|
-
"legacy": true,
|
90
|
-
"pricing": {
|
91
|
-
"input": 1.5,
|
92
|
-
"output": 2,
|
93
|
-
},
|
94
|
-
"tokens": 4096,
|
95
72
|
},
|
96
73
|
{
|
97
74
|
"description": "GPT 3.5 Turbo,适用于各种文本生成和理解任务,Currently points to gpt-3.5-turbo-0125",
|
@@ -1,8 +1,34 @@
|
|
1
|
-
import { ModelProvider } from '../types';
|
1
|
+
import { ChatStreamPayload, ModelProvider, OpenAIChatMessage } from '../types';
|
2
2
|
import { LobeOpenAICompatibleFactory } from '../utils/openaiCompatibleFactory';
|
3
3
|
|
4
|
+
// TODO: 临时写法,后续要重构成 model card 展示配置
|
5
|
+
const o1Models = new Set(['o1-preview', 'o1-mini']);
|
6
|
+
const truneO1Payload = (payload: ChatStreamPayload) => ({
|
7
|
+
...payload,
|
8
|
+
frequency_penalty: 0,
|
9
|
+
messages: payload.messages.map((message: OpenAIChatMessage) => ({
|
10
|
+
...message,
|
11
|
+
role: message.role === 'system' ? 'user' : message.role,
|
12
|
+
})),
|
13
|
+
presence_penalty: 0,
|
14
|
+
stream: false,
|
15
|
+
temperature: 1,
|
16
|
+
top_p: 1,
|
17
|
+
});
|
18
|
+
|
4
19
|
export const LobeOpenAI = LobeOpenAICompatibleFactory({
|
5
20
|
baseURL: 'https://api.openai.com/v1',
|
21
|
+
chatCompletion: {
|
22
|
+
handlePayload: (payload) => {
|
23
|
+
const { model } = payload;
|
24
|
+
|
25
|
+
if (o1Models.has(model)) {
|
26
|
+
return truneO1Payload(payload) as any;
|
27
|
+
}
|
28
|
+
|
29
|
+
return { ...payload, stream: payload.stream ?? true };
|
30
|
+
},
|
31
|
+
},
|
6
32
|
debug: {
|
7
33
|
chatCompletion: () => process.env.DEBUG_OPENAI_CHAT_COMPLETION === '1',
|
8
34
|
},
|
@@ -6,6 +6,7 @@ import { getLLMConfig } from '@/config/llm';
|
|
6
6
|
import {
|
7
7
|
BedrockProviderCard,
|
8
8
|
FireworksAIProviderCard,
|
9
|
+
GoogleProviderCard,
|
9
10
|
GroqProviderCard,
|
10
11
|
NovitaProviderCard,
|
11
12
|
OllamaProviderCard,
|
@@ -39,6 +40,7 @@ export const getServerGlobalConfig = () => {
|
|
39
40
|
AWS_BEDROCK_MODEL_LIST,
|
40
41
|
|
41
42
|
ENABLED_GOOGLE,
|
43
|
+
GOOGLE_MODEL_LIST,
|
42
44
|
|
43
45
|
ENABLED_GROQ,
|
44
46
|
GROQ_MODEL_LIST,
|
@@ -128,7 +130,14 @@ export const getServerGlobalConfig = () => {
|
|
128
130
|
}),
|
129
131
|
},
|
130
132
|
|
131
|
-
google: {
|
133
|
+
google: {
|
134
|
+
enabled: ENABLED_GOOGLE,
|
135
|
+
enabledModels: extractEnabledModels(GOOGLE_MODEL_LIST),
|
136
|
+
serverModelCards: transformToChatModelCards({
|
137
|
+
defaultChatModels: GoogleProviderCard.chatModels,
|
138
|
+
modelString: GOOGLE_MODEL_LIST,
|
139
|
+
}),
|
140
|
+
},
|
132
141
|
groq: {
|
133
142
|
enabled: ENABLED_GROQ,
|
134
143
|
enabledModels: extractEnabledModels(GROQ_MODEL_LIST),
|
@@ -61,18 +61,6 @@ exports[`configRouter > getGlobalConfig > Model Provider env > OPENAI_MODEL_LIST
|
|
61
61
|
},
|
62
62
|
"tokens": 16385,
|
63
63
|
},
|
64
|
-
{
|
65
|
-
"description": "GPT 3.5 Turbo,适用于各种文本生成和理解任务,Currently points to gpt-3.5-turbo-0125",
|
66
|
-
"displayName": "GPT-3.5 Turbo 16K",
|
67
|
-
"enabled": true,
|
68
|
-
"id": "gpt-3.5-turbo-16k",
|
69
|
-
"legacy": true,
|
70
|
-
"pricing": {
|
71
|
-
"input": 3,
|
72
|
-
"output": 4,
|
73
|
-
},
|
74
|
-
"tokens": 16385,
|
75
|
-
},
|
76
64
|
{
|
77
65
|
"description": "GPT-4 提供了一个更大的上下文窗口,能够处理更长的文本输入,适用于需要广泛信息整合和数据分析的场景。",
|
78
66
|
"displayName": "GPT-4",
|
@@ -45,7 +45,7 @@ describe('configRouter', () => {
|
|
45
45
|
|
46
46
|
it('should work correct with gpt-4', async () => {
|
47
47
|
process.env.OPENAI_MODEL_LIST =
|
48
|
-
'-all,+gpt-3.5-turbo-1106,+gpt-3.5-turbo,+gpt-
|
48
|
+
'-all,+gpt-3.5-turbo-1106,+gpt-3.5-turbo,+gpt-4,+gpt-4-32k,+gpt-4-1106-preview,+gpt-4-vision-preview';
|
49
49
|
|
50
50
|
const response = await router.getGlobalConfig();
|
51
51
|
|
@@ -49,7 +49,14 @@ describe('modelProviderSelectors', () => {
|
|
49
49
|
const s = merge(initialState, {}) as unknown as UserStore;
|
50
50
|
|
51
51
|
const result = modelProviderSelectors.getDefaultEnabledModelsById('openai')(s);
|
52
|
-
expect(result).toEqual([
|
52
|
+
expect(result).toEqual([
|
53
|
+
'o1-mini',
|
54
|
+
'o1-preview',
|
55
|
+
'gpt-4o-mini',
|
56
|
+
'gpt-4o',
|
57
|
+
'gpt-4o-2024-08-06',
|
58
|
+
'chatgpt-4o-latest',
|
59
|
+
]);
|
53
60
|
});
|
54
61
|
|
55
62
|
it('should return undefined for a non-existing provider', () => {
|