@lobehub/chat 0.147.21 → 0.148.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.
- package/CHANGELOG.md +42 -0
- package/locales/ar/setting.json +4 -0
- package/locales/bg-BG/setting.json +4 -0
- package/locales/de-DE/setting.json +4 -0
- package/locales/en-US/setting.json +4 -0
- package/locales/es-ES/setting.json +4 -0
- package/locales/fr-FR/setting.json +4 -0
- package/locales/it-IT/setting.json +4 -0
- package/locales/ja-JP/setting.json +4 -0
- package/locales/ko-KR/setting.json +4 -0
- package/locales/nl-NL/setting.json +4 -0
- package/locales/pl-PL/setting.json +4 -0
- package/locales/pt-BR/setting.json +4 -0
- package/locales/ru-RU/setting.json +4 -0
- package/locales/tr-TR/setting.json +4 -0
- package/locales/vi-VN/setting.json +4 -0
- package/locales/zh-CN/setting.json +4 -0
- package/locales/zh-TW/setting.json +4 -0
- package/package.json +3 -2
- package/public/favicon-32x32.ico +0 -0
- package/public/favicon.ico +0 -0
- package/public/icons/apple-touch-icon.png +0 -0
- package/src/app/api/chat/[provider]/route.test.ts +5 -7
- package/src/app/api/chat/[provider]/route.ts +13 -7
- package/src/app/api/chat/agentRuntime.test.ts +195 -451
- package/src/app/api/chat/agentRuntime.ts +197 -280
- package/src/app/api/chat/models/[provider]/route.ts +2 -2
- package/src/app/chat/features/TopicListContent/Topic/TopicContent.tsx +2 -2
- package/src/app/metadata.ts +3 -5
- package/src/app/settings/llm/components/ProviderConfig/index.tsx +23 -1
- package/src/app/settings/llm/index.tsx +2 -2
- package/src/app/settings/llm/page.tsx +1 -5
- package/src/features/ChatInput/Topic/index.tsx +6 -2
- package/src/features/Conversation/components/ChatItem/index.tsx +8 -3
- package/src/libs/agent-runtime/AgentRuntime.test.ts +400 -0
- package/src/libs/agent-runtime/AgentRuntime.ts +192 -0
- package/src/libs/agent-runtime/index.ts +1 -0
- package/src/libs/swr/index.ts +9 -0
- package/src/locales/default/setting.ts +4 -0
- package/src/services/__tests__/chat.test.ts +287 -1
- package/src/services/chat.ts +148 -2
- package/src/store/chat/slices/message/action.ts +80 -42
- package/src/store/chat/slices/message/initialState.ts +1 -1
- package/src/store/chat/slices/message/reducer.ts +32 -1
- package/src/store/chat/slices/topic/action.test.ts +25 -2
- package/src/store/chat/slices/topic/action.ts +24 -7
- package/src/store/chat/slices/topic/reducer.test.ts +141 -0
- package/src/store/chat/slices/topic/reducer.ts +67 -0
- package/src/store/global/slices/settings/selectors/modelConfig.ts +13 -0
- package/src/store/session/slices/session/action.ts +4 -5
- package/src/types/settings/modelProvider.ts +4 -0
- package/vercel.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,48 @@
|
|
|
2
2
|
|
|
3
3
|
# Changelog
|
|
4
4
|
|
|
5
|
+
## [Version 0.148.0](https://github.com/lobehub/lobe-chat/compare/v0.147.22...v0.148.0)
|
|
6
|
+
|
|
7
|
+
<sup>Released on **2024-04-20**</sup>
|
|
8
|
+
|
|
9
|
+
#### ✨ Features
|
|
10
|
+
|
|
11
|
+
- **misc**: Support chat completion call at client side.
|
|
12
|
+
|
|
13
|
+
<br/>
|
|
14
|
+
|
|
15
|
+
<details>
|
|
16
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
|
17
|
+
|
|
18
|
+
#### What's improved
|
|
19
|
+
|
|
20
|
+
- **misc**: Support chat completion call at client side, closes [#2041](https://github.com/lobehub/lobe-chat/issues/2041) ([9f5858f](https://github.com/lobehub/lobe-chat/commit/9f5858f))
|
|
21
|
+
|
|
22
|
+
</details>
|
|
23
|
+
|
|
24
|
+
<div align="right">
|
|
25
|
+
|
|
26
|
+
[](#readme-top)
|
|
27
|
+
|
|
28
|
+
</div>
|
|
29
|
+
|
|
30
|
+
### [Version 0.147.22](https://github.com/lobehub/lobe-chat/compare/v0.147.21...v0.147.22)
|
|
31
|
+
|
|
32
|
+
<sup>Released on **2024-04-19**</sup>
|
|
33
|
+
|
|
34
|
+
<br/>
|
|
35
|
+
|
|
36
|
+
<details>
|
|
37
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
|
38
|
+
|
|
39
|
+
</details>
|
|
40
|
+
|
|
41
|
+
<div align="right">
|
|
42
|
+
|
|
43
|
+
[](#readme-top)
|
|
44
|
+
|
|
45
|
+
</div>
|
|
46
|
+
|
|
5
47
|
### [Version 0.147.21](https://github.com/lobehub/lobe-chat/compare/v0.147.20...v0.147.21)
|
|
6
48
|
|
|
7
49
|
<sup>Released on **2024-04-19**</sup>
|
package/locales/ar/setting.json
CHANGED
|
@@ -75,6 +75,10 @@
|
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
},
|
|
78
|
+
"fetchOnClient": {
|
|
79
|
+
"desc": "طريقة طلب العميل ستبدأ طلب الجلسة مباشرة من المتصفح، مما يمكن أن يعزز سرعة الاستجابة",
|
|
80
|
+
"title": "استخدام طريقة طلب العميل"
|
|
81
|
+
},
|
|
78
82
|
"fetcher": {
|
|
79
83
|
"fetch": "احصل على قائمة النماذج",
|
|
80
84
|
"fetching": "جاري الحصول على قائمة النماذج...",
|
|
@@ -75,6 +75,10 @@
|
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
},
|
|
78
|
+
"fetchOnClient": {
|
|
79
|
+
"desc": "Режимът на заявка от клиента стартира заявката директно от браузъра, което може да увеличи скоростта на отговора",
|
|
80
|
+
"title": "Използване на режим на заявка от клиента"
|
|
81
|
+
},
|
|
78
82
|
"fetcher": {
|
|
79
83
|
"fetch": "Изтегляне на списъка с модели",
|
|
80
84
|
"fetching": "Изтегляне на списъка с модели...",
|
|
@@ -75,6 +75,10 @@
|
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
},
|
|
78
|
+
"fetchOnClient": {
|
|
79
|
+
"desc": "Client Fetch-Modus initiiert direkte Sitzungsanfragen vom Browser aus und verbessert die Reaktionsgeschwindigkeit.",
|
|
80
|
+
"title": "Client Fetch-Modus verwenden"
|
|
81
|
+
},
|
|
78
82
|
"fetcher": {
|
|
79
83
|
"fetch": "Modelle abrufen",
|
|
80
84
|
"fetching": "Modelle werden abgerufen...",
|
|
@@ -75,6 +75,10 @@
|
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
},
|
|
78
|
+
"fetchOnClient": {
|
|
79
|
+
"desc": "Client-side fetching mode initiates session requests directly from the browser, improving response speed.",
|
|
80
|
+
"title": "Use Client-Side Fetching Mode"
|
|
81
|
+
},
|
|
78
82
|
"fetcher": {
|
|
79
83
|
"fetch": "Get Model List",
|
|
80
84
|
"fetching": "Fetching Model List...",
|
|
@@ -75,6 +75,10 @@
|
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
},
|
|
78
|
+
"fetchOnClient": {
|
|
79
|
+
"desc": "El modo de solicitud en el cliente iniciará directamente la solicitud de sesión desde el navegador, lo que puede mejorar la velocidad de respuesta",
|
|
80
|
+
"title": "Usar el modo de solicitud en el cliente"
|
|
81
|
+
},
|
|
78
82
|
"fetcher": {
|
|
79
83
|
"fetch": "Obtener lista de modelos",
|
|
80
84
|
"fetching": "Obteniendo lista de modelos...",
|
|
@@ -75,6 +75,10 @@
|
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
},
|
|
78
|
+
"fetchOnClient": {
|
|
79
|
+
"desc": "Le mode de requête client lancera directement une session à partir du navigateur, améliorant ainsi la vitesse de réponse",
|
|
80
|
+
"title": "Utiliser le mode de requête client"
|
|
81
|
+
},
|
|
78
82
|
"fetcher": {
|
|
79
83
|
"fetch": "Obtenir la liste des modèles",
|
|
80
84
|
"fetching": "Récupération de la liste des modèles en cours...",
|
|
@@ -75,6 +75,10 @@
|
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
},
|
|
78
|
+
"fetchOnClient": {
|
|
79
|
+
"desc": "Il modo di richiesta del client consente di avviare direttamente una richiesta di sessione dal browser, migliorando i tempi di risposta",
|
|
80
|
+
"title": "Utilizzo del modo di richiesta del client"
|
|
81
|
+
},
|
|
78
82
|
"fetcher": {
|
|
79
83
|
"fetch": "Ottenere l'elenco dei modelli",
|
|
80
84
|
"fetching": "Recupero dell'elenco dei modelli in corso...",
|
|
@@ -75,6 +75,10 @@
|
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
},
|
|
78
|
+
"fetchOnClient": {
|
|
79
|
+
"desc": "O modo de solicitação do cliente iniciará diretamente a solicitação da sessão a partir do navegador, melhorando a velocidade de resposta",
|
|
80
|
+
"title": "Usar o modo de solicitação do cliente"
|
|
81
|
+
},
|
|
78
82
|
"fetcher": {
|
|
79
83
|
"fetch": "Obter lista de modelos",
|
|
80
84
|
"fetching": "Obtendo lista de modelos...",
|
|
@@ -75,6 +75,10 @@
|
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
},
|
|
78
|
+
"fetchOnClient": {
|
|
79
|
+
"desc": "Режим запроса с клиента позволяет инициировать запрос сеанса непосредственно из браузера, что улучшает скорость ответа",
|
|
80
|
+
"title": "Использовать режим запроса с клиента"
|
|
81
|
+
},
|
|
78
82
|
"fetcher": {
|
|
79
83
|
"fetch": "Получить список моделей",
|
|
80
84
|
"fetching": "Идет получение списка моделей...",
|
|
@@ -75,6 +75,10 @@
|
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
},
|
|
78
|
+
"fetchOnClient": {
|
|
79
|
+
"desc": "İstemci tarafından alınan veri: Tarayıcı, doğrudan oturum isteği gönderir ve yanıt hızını artırabilir.",
|
|
80
|
+
"title": "İstemci Tarafından Veri Alımı"
|
|
81
|
+
},
|
|
78
82
|
"fetcher": {
|
|
79
83
|
"fetch": "Modelleri Al",
|
|
80
84
|
"fetching": "Modelleri alınıyor...",
|
|
@@ -75,6 +75,10 @@
|
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
},
|
|
78
|
+
"fetchOnClient": {
|
|
79
|
+
"desc": "Chế độ yêu cầu từ khách hàng sẽ khởi động yêu cầu phiên trực tiếp từ trình duyệt, có thể cải thiện tốc độ phản hồi",
|
|
80
|
+
"title": "Sử dụng chế độ yêu cầu từ khách hàng"
|
|
81
|
+
},
|
|
78
82
|
"fetcher": {
|
|
79
83
|
"fetch": "Lấy danh sách mô hình",
|
|
80
84
|
"fetching": "Đang lấy danh sách mô hình...",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lobehub/chat",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.148.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",
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
"@aws-sdk/client-bedrock-runtime": "^3.549.0",
|
|
87
87
|
"@azure/openai": "^1.0.0-beta.12",
|
|
88
88
|
"@cfworker/json-schema": "^1.12.8",
|
|
89
|
-
"@google/generative-ai": "^0.
|
|
89
|
+
"@google/generative-ai": "^0.7.0",
|
|
90
90
|
"@icons-pack/react-simple-icons": "^9.4.0",
|
|
91
91
|
"@lobehub/chat-plugin-sdk": "latest",
|
|
92
92
|
"@lobehub/chat-plugins-gateway": "latest",
|
|
@@ -207,6 +207,7 @@
|
|
|
207
207
|
"lodash": "^4.17.21",
|
|
208
208
|
"markdown-table": "^3.0.3",
|
|
209
209
|
"node-fetch": "^3.3.2",
|
|
210
|
+
"node-gyp": "^10.1.0",
|
|
210
211
|
"p-map": "^7.0.2",
|
|
211
212
|
"prettier": "^3.2.5",
|
|
212
213
|
"remark-cli": "^11.0.0",
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -2,10 +2,9 @@
|
|
|
2
2
|
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
3
3
|
|
|
4
4
|
import { LOBE_CHAT_AUTH_HEADER, OAUTH_AUTHORIZED } from '@/const/auth';
|
|
5
|
-
import { LobeRuntimeAI } from '@/libs/agent-runtime';
|
|
5
|
+
import { AgentRuntime, LobeRuntimeAI } from '@/libs/agent-runtime';
|
|
6
6
|
import { ChatErrorType } from '@/types/fetch';
|
|
7
7
|
|
|
8
|
-
import AgentRuntime from '../agentRuntime';
|
|
9
8
|
import { getJWTPayload } from '../auth/utils';
|
|
10
9
|
import { POST } from './route';
|
|
11
10
|
|
|
@@ -37,7 +36,7 @@ describe('POST handler', () => {
|
|
|
37
36
|
it('should initialize AgentRuntime correctly with valid authorization', async () => {
|
|
38
37
|
const mockParams = { provider: 'test-provider' };
|
|
39
38
|
|
|
40
|
-
// 设置 getJWTPayload 和
|
|
39
|
+
// 设置 getJWTPayload 和 initAgentRuntimeWithUserPayload 的模拟返回值
|
|
41
40
|
vi.mocked(getJWTPayload).mockResolvedValue({
|
|
42
41
|
accessCode: 'test-access-code',
|
|
43
42
|
apiKey: 'test-api-key',
|
|
@@ -46,8 +45,9 @@ describe('POST handler', () => {
|
|
|
46
45
|
|
|
47
46
|
const mockRuntime: LobeRuntimeAI = { baseURL: 'abc', chat: vi.fn() };
|
|
48
47
|
|
|
48
|
+
// migrate to new AgentRuntime init api
|
|
49
49
|
const spy = vi
|
|
50
|
-
.spyOn(AgentRuntime, '
|
|
50
|
+
.spyOn(AgentRuntime, 'initializeWithProviderOptions')
|
|
51
51
|
.mockResolvedValue(new AgentRuntime(mockRuntime));
|
|
52
52
|
|
|
53
53
|
// 调用 POST 函数
|
|
@@ -110,9 +110,7 @@ describe('POST handler', () => {
|
|
|
110
110
|
const response = await POST(request as unknown as Request, { params: mockParams });
|
|
111
111
|
|
|
112
112
|
expect(response).toEqual(mockChatResponse);
|
|
113
|
-
expect(AgentRuntime.prototype.chat).toHaveBeenCalledWith(mockChatPayload
|
|
114
|
-
provider: 'test-provider',
|
|
115
|
-
});
|
|
113
|
+
expect(AgentRuntime.prototype.chat).toHaveBeenCalledWith(mockChatPayload);
|
|
116
114
|
});
|
|
117
115
|
|
|
118
116
|
it('should return an error response when chat completion fails', async () => {
|
|
@@ -5,7 +5,7 @@ import { ChatErrorType } from '@/types/fetch';
|
|
|
5
5
|
import { ChatStreamPayload } from '@/types/openai/chat';
|
|
6
6
|
import { getTracePayload } from '@/utils/trace';
|
|
7
7
|
|
|
8
|
-
import
|
|
8
|
+
import { createTraceOptions, initAgentRuntimeWithUserPayload } from '../agentRuntime';
|
|
9
9
|
import { checkAuth } from '../auth';
|
|
10
10
|
|
|
11
11
|
export const runtime = 'edge';
|
|
@@ -17,7 +17,7 @@ export const POST = checkAuth(async (req: Request, { params, jwtPayload }) => {
|
|
|
17
17
|
|
|
18
18
|
try {
|
|
19
19
|
// ============ 1. init chat model ============ //
|
|
20
|
-
const agentRuntime = await
|
|
20
|
+
const agentRuntime = await initAgentRuntimeWithUserPayload(provider, jwtPayload);
|
|
21
21
|
|
|
22
22
|
// ============ 2. create chat completion ============ //
|
|
23
23
|
|
|
@@ -25,11 +25,17 @@ export const POST = checkAuth(async (req: Request, { params, jwtPayload }) => {
|
|
|
25
25
|
|
|
26
26
|
const tracePayload = getTracePayload(req);
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
// If user enable trace
|
|
29
|
+
if (tracePayload?.enabled) {
|
|
30
|
+
return await agentRuntime.chat(
|
|
31
|
+
data,
|
|
32
|
+
createTraceOptions(data, {
|
|
33
|
+
provider,
|
|
34
|
+
trace: tracePayload,
|
|
35
|
+
}),
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
return await agentRuntime.chat(data);
|
|
33
39
|
} catch (e) {
|
|
34
40
|
const {
|
|
35
41
|
errorType = ChatErrorType.InternalServerError,
|