@lobehub/chat 0.107.3 → 0.107.5
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
CHANGED
|
@@ -2,6 +2,56 @@
|
|
|
2
2
|
|
|
3
3
|
# Changelog
|
|
4
4
|
|
|
5
|
+
### [Version 0.107.5](https://github.com/lobehub/lobe-chat/compare/v0.107.4...v0.107.5)
|
|
6
|
+
|
|
7
|
+
<sup>Released on **2023-11-30**</sup>
|
|
8
|
+
|
|
9
|
+
#### 🐛 Bug Fixes
|
|
10
|
+
|
|
11
|
+
- **misc**: 修正调用插件查询的显示问题.
|
|
12
|
+
|
|
13
|
+
<br/>
|
|
14
|
+
|
|
15
|
+
<details>
|
|
16
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
|
17
|
+
|
|
18
|
+
#### What's fixed
|
|
19
|
+
|
|
20
|
+
- **misc**: 修正调用插件查询的显示问题 ([1457fe8](https://github.com/lobehub/lobe-chat/commit/1457fe8))
|
|
21
|
+
|
|
22
|
+
</details>
|
|
23
|
+
|
|
24
|
+
<div align="right">
|
|
25
|
+
|
|
26
|
+
[](#readme-top)
|
|
27
|
+
|
|
28
|
+
</div>
|
|
29
|
+
|
|
30
|
+
### [Version 0.107.4](https://github.com/lobehub/lobe-chat/compare/v0.107.3...v0.107.4)
|
|
31
|
+
|
|
32
|
+
<sup>Released on **2023-11-30**</sup>
|
|
33
|
+
|
|
34
|
+
#### 🐛 Bug Fixes
|
|
35
|
+
|
|
36
|
+
- **misc**: Fix a bug that remove all topics when clear message.
|
|
37
|
+
|
|
38
|
+
<br/>
|
|
39
|
+
|
|
40
|
+
<details>
|
|
41
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
|
42
|
+
|
|
43
|
+
#### What's fixed
|
|
44
|
+
|
|
45
|
+
- **misc**: Fix a bug that remove all topics when clear message ([1ab912d](https://github.com/lobehub/lobe-chat/commit/1ab912d))
|
|
46
|
+
|
|
47
|
+
</details>
|
|
48
|
+
|
|
49
|
+
<div align="right">
|
|
50
|
+
|
|
51
|
+
[](#readme-top)
|
|
52
|
+
|
|
53
|
+
</div>
|
|
54
|
+
|
|
5
55
|
### [Version 0.107.3](https://github.com/lobehub/lobe-chat/compare/v0.107.2...v0.107.3)
|
|
6
56
|
|
|
7
57
|
<sup>Released on **2023-11-30**</sup>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lobehub/chat",
|
|
3
|
-
"version": "0.107.
|
|
3
|
+
"version": "0.107.5",
|
|
4
4
|
"description": "An open-source, extensible (Function Calling), high-performance chatbot framework. It supports one-click free deployment of your private ChatGPT/LLM web application",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"chatbot",
|
|
@@ -34,7 +34,12 @@ class _DEBUG_MODEL extends BaseModel<'sessions'> {
|
|
|
34
34
|
return array[randomIndex];
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
createRandomData = async ({
|
|
37
|
+
createRandomData = async ({
|
|
38
|
+
sessionCount = 10,
|
|
39
|
+
topicCount = 2000,
|
|
40
|
+
messageCount = 10_000,
|
|
41
|
+
startIndex = 1,
|
|
42
|
+
}) => {
|
|
38
43
|
const numberOfSessions = sessionCount;
|
|
39
44
|
const numberOfTopics = topicCount;
|
|
40
45
|
const numberOfMessages = messageCount;
|
|
@@ -45,7 +50,7 @@ class _DEBUG_MODEL extends BaseModel<'sessions'> {
|
|
|
45
50
|
const messagesData: DBModel<DB_Message>[] = [];
|
|
46
51
|
|
|
47
52
|
// Prepare sessions
|
|
48
|
-
for (let i =
|
|
53
|
+
for (let i = startIndex; i < numberOfSessions + startIndex; i++) {
|
|
49
54
|
sessionsData.push({
|
|
50
55
|
config: DEFAULT_AGENT_CONFIG,
|
|
51
56
|
createdAt: this.randomDate(new Date(2020, 0, 1), new Date()),
|
|
@@ -61,30 +66,30 @@ class _DEBUG_MODEL extends BaseModel<'sessions'> {
|
|
|
61
66
|
}
|
|
62
67
|
|
|
63
68
|
// Prepare topics
|
|
64
|
-
for (let i =
|
|
69
|
+
for (let i = startIndex; i < numberOfTopics + startIndex; i++) {
|
|
65
70
|
topicsData.push({
|
|
66
71
|
createdAt: this.randomDate(new Date(2020, 0, 1), new Date()),
|
|
67
72
|
favorite: this.getRandomInt(0, 1),
|
|
68
73
|
id: `topic_${i}`,
|
|
69
|
-
sessionId: `sess_${this.getRandomInt(
|
|
74
|
+
sessionId: `sess_${this.getRandomInt(startIndex, numberOfSessions)}`,
|
|
70
75
|
title: `Topic Title ${i}`,
|
|
71
76
|
updatedAt: this.randomDate(new Date(2020, 0, 1), new Date()),
|
|
72
77
|
});
|
|
73
78
|
}
|
|
74
79
|
|
|
75
80
|
// Prepare messages
|
|
76
|
-
for (let i =
|
|
81
|
+
for (let i = startIndex; i < numberOfMessages + startIndex; i++) {
|
|
77
82
|
messagesData.push({
|
|
78
83
|
content: this.randomString(300),
|
|
79
84
|
createdAt: this.randomDate(new Date(2020, 0, 1), new Date()),
|
|
80
85
|
favorite: this.getRandomInt(0, 1),
|
|
81
86
|
fromModel: 'model',
|
|
82
87
|
id: `msg_${i}`,
|
|
83
|
-
parentId: `msg_${this.getRandomInt(
|
|
84
|
-
quotaId: `msg_${this.getRandomInt(
|
|
88
|
+
parentId: `msg_${this.getRandomInt(startIndex, numberOfMessages)}`,
|
|
89
|
+
quotaId: `msg_${this.getRandomInt(startIndex, numberOfMessages)}`,
|
|
85
90
|
role: this.randomPick(['user', 'assistant']),
|
|
86
|
-
sessionId: `sess_${this.getRandomInt(
|
|
87
|
-
topicId: `topic_${this.getRandomInt(
|
|
91
|
+
sessionId: `sess_${this.getRandomInt(startIndex, numberOfSessions)}`,
|
|
92
|
+
topicId: `topic_${this.getRandomInt(startIndex, numberOfTopics)}`,
|
|
88
93
|
updatedAt: this.randomDate(new Date(2020, 0, 1), new Date()),
|
|
89
94
|
});
|
|
90
95
|
}
|
package/src/services/debug.ts
CHANGED
|
@@ -2,11 +2,38 @@ import { DEBUG_MODEL } from '@/database/models/__DEBUG';
|
|
|
2
2
|
|
|
3
3
|
class DebugService {
|
|
4
4
|
async insertLargeDataToDB() {
|
|
5
|
-
|
|
6
|
-
messageCount:
|
|
5
|
+
await DEBUG_MODEL.createRandomData({
|
|
6
|
+
messageCount: 100_000,
|
|
7
7
|
sessionCount: 40,
|
|
8
|
+
startIndex: 0,
|
|
8
9
|
topicCount: 200,
|
|
9
10
|
});
|
|
11
|
+
|
|
12
|
+
console.log('已插入10w');
|
|
13
|
+
|
|
14
|
+
await DEBUG_MODEL.createRandomData({
|
|
15
|
+
messageCount: 300_000,
|
|
16
|
+
sessionCount: 40,
|
|
17
|
+
startIndex: 100_001,
|
|
18
|
+
topicCount: 200,
|
|
19
|
+
});
|
|
20
|
+
console.log('已插入40w');
|
|
21
|
+
|
|
22
|
+
await DEBUG_MODEL.createRandomData({
|
|
23
|
+
messageCount: 300_000,
|
|
24
|
+
sessionCount: 40,
|
|
25
|
+
startIndex: 400_001,
|
|
26
|
+
topicCount: 200,
|
|
27
|
+
});
|
|
28
|
+
console.log('已插入70w');
|
|
29
|
+
|
|
30
|
+
await DEBUG_MODEL.createRandomData({
|
|
31
|
+
messageCount: 300_000,
|
|
32
|
+
sessionCount: 40,
|
|
33
|
+
startIndex: 700_001,
|
|
34
|
+
topicCount: 200,
|
|
35
|
+
});
|
|
36
|
+
console.log('已插入100w');
|
|
10
37
|
}
|
|
11
38
|
}
|
|
12
39
|
|
package/src/services/message.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CreateMessageParams, MessageModel } from '@/database/models/message';
|
|
2
|
+
import { DB_Message } from '@/database/schemas/message';
|
|
2
3
|
import {
|
|
3
4
|
ChatMessage,
|
|
4
5
|
ChatMessageError,
|
|
@@ -64,6 +65,10 @@ export class MessageService {
|
|
|
64
65
|
return MessageModel.batchUpdate(messageIds, { topicId });
|
|
65
66
|
}
|
|
66
67
|
|
|
68
|
+
async updateMessage(id: string, message: Partial<DB_Message>) {
|
|
69
|
+
return MessageModel.update(id, message);
|
|
70
|
+
}
|
|
71
|
+
|
|
67
72
|
async updateMessageRole(id: string, role: LLMRoleType) {
|
|
68
73
|
return MessageModel.update(id, { role });
|
|
69
74
|
}
|
|
@@ -94,7 +94,7 @@ export const chatMessage: StateCreator<
|
|
|
94
94
|
await messageService.removeMessages(activeId, activeTopicId);
|
|
95
95
|
|
|
96
96
|
if (activeTopicId) {
|
|
97
|
-
await topicService.
|
|
97
|
+
await topicService.removeTopic(activeTopicId);
|
|
98
98
|
}
|
|
99
99
|
await refreshTopic();
|
|
100
100
|
await refreshMessages();
|
|
@@ -249,6 +249,7 @@ export const chatMessage: StateCreator<
|
|
|
249
249
|
// 2. fetch the AI response
|
|
250
250
|
const { isFunctionCall, content, functionCallAtEnd, functionCallContent } =
|
|
251
251
|
await fetchAIChatMessage(messages, mid);
|
|
252
|
+
await messageService.updateMessageContent(mid, content);
|
|
252
253
|
|
|
253
254
|
// 3. if it's the function call message, trigger the function method
|
|
254
255
|
if (isFunctionCall) {
|
|
@@ -271,9 +272,9 @@ export const chatMessage: StateCreator<
|
|
|
271
272
|
topicId: activeTopicId,
|
|
272
273
|
};
|
|
273
274
|
functionId = await messageService.create(functionMessage);
|
|
274
|
-
await refreshMessages();
|
|
275
275
|
}
|
|
276
276
|
|
|
277
|
+
await refreshMessages();
|
|
277
278
|
triggerFunctionCall(functionId);
|
|
278
279
|
}
|
|
279
280
|
},
|
|
@@ -287,7 +288,7 @@ export const chatMessage: StateCreator<
|
|
|
287
288
|
set({ messages }, false, t(`dispatchMessage/${payload.type}`, payload));
|
|
288
289
|
},
|
|
289
290
|
fetchAIChatMessage: async (messages, assistantId) => {
|
|
290
|
-
const {
|
|
291
|
+
const { toggleChatLoading, refreshMessages } = get();
|
|
291
292
|
|
|
292
293
|
const abortController = toggleChatLoading(
|
|
293
294
|
true,
|
|
@@ -361,11 +362,11 @@ export const chatMessage: StateCreator<
|
|
|
361
362
|
// update the content after fetch result
|
|
362
363
|
await messageService.updateMessageContent(assistantId, content);
|
|
363
364
|
},
|
|
364
|
-
onMessageHandle: (text) => {
|
|
365
|
+
onMessageHandle: async (text) => {
|
|
365
366
|
output += text;
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
367
|
+
|
|
368
|
+
await messageService.updateMessageContent(assistantId, output);
|
|
369
|
+
await refreshMessages();
|
|
369
370
|
|
|
370
371
|
// is this message is just a function call
|
|
371
372
|
if (isFunctionMessageAtStart(output)) isFunctionCall = true;
|
|
@@ -81,14 +81,14 @@ export const chatPlugin: StateCreator<
|
|
|
81
81
|
};
|
|
82
82
|
|
|
83
83
|
await messageService.updateMessageContent(id, '');
|
|
84
|
+
await refreshMessages();
|
|
84
85
|
} else {
|
|
85
86
|
if (message.plugin) payload = message.plugin;
|
|
86
87
|
}
|
|
87
88
|
|
|
88
89
|
if (!payload.apiName) return;
|
|
89
90
|
|
|
90
|
-
await messageService.
|
|
91
|
-
await messageService.updateMessagePlugin(id, payload);
|
|
91
|
+
await messageService.updateMessage(id, { plugin: payload, role: 'function' });
|
|
92
92
|
await refreshMessages();
|
|
93
93
|
|
|
94
94
|
if (payload.type === 'standalone') {
|