@lobehub/chat 1.49.12 → 1.49.13
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 +25 -0
- package/changelog/v1.json +9 -0
- package/package.json +3 -3
- package/src/store/chat/helpers.test.ts +7 -1
- package/src/store/chat/helpers.ts +3 -3
package/CHANGELOG.md
CHANGED
@@ -2,6 +2,31 @@
|
|
2
2
|
|
3
3
|
# Changelog
|
4
4
|
|
5
|
+
### [Version 1.49.13](https://github.com/lobehub/lobe-chat/compare/v1.49.12...v1.49.13)
|
6
|
+
|
7
|
+
<sup>Released on **2025-02-03**</sup>
|
8
|
+
|
9
|
+
#### 🐛 Bug Fixes
|
10
|
+
|
11
|
+
- **misc**: Optimize requests without historical messages.
|
12
|
+
|
13
|
+
<br/>
|
14
|
+
|
15
|
+
<details>
|
16
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
17
|
+
|
18
|
+
#### What's fixed
|
19
|
+
|
20
|
+
- **misc**: Optimize requests without historical messages, closes [#5174](https://github.com/lobehub/lobe-chat/issues/5174) ([182f8d9](https://github.com/lobehub/lobe-chat/commit/182f8d9))
|
21
|
+
|
22
|
+
</details>
|
23
|
+
|
24
|
+
<div align="right">
|
25
|
+
|
26
|
+
[](#readme-top)
|
27
|
+
|
28
|
+
</div>
|
29
|
+
|
5
30
|
### [Version 1.49.12](https://github.com/lobehub/lobe-chat/compare/v1.49.11...v1.49.12)
|
6
31
|
|
7
32
|
<sup>Released on **2025-02-02**</sup>
|
package/changelog/v1.json
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@lobehub/chat",
|
3
|
-
"version": "1.49.
|
3
|
+
"version": "1.49.13",
|
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",
|
@@ -114,7 +114,7 @@
|
|
114
114
|
"@baiducloud/qianfan": "^0.1.9",
|
115
115
|
"@cfworker/json-schema": "^4.1.0",
|
116
116
|
"@clerk/localizations": "^3.9.6",
|
117
|
-
"@clerk/nextjs": "6.10.
|
117
|
+
"@clerk/nextjs": "^6.10.6",
|
118
118
|
"@clerk/themes": "^2.2.4",
|
119
119
|
"@codesandbox/sandpack-react": "^2.19.10",
|
120
120
|
"@cyntler/react-doc-viewer": "^1.17.0",
|
@@ -154,7 +154,7 @@
|
|
154
154
|
"debug": "^4.4.0",
|
155
155
|
"dexie": "^3.2.7",
|
156
156
|
"diff": "^7.0.0",
|
157
|
-
"drizzle-orm": "^0.
|
157
|
+
"drizzle-orm": "^0.39.0",
|
158
158
|
"drizzle-zod": "^0.5.1",
|
159
159
|
"fast-deep-equal": "^3.1.3",
|
160
160
|
"file-type": "^19.6.0",
|
@@ -74,7 +74,7 @@ describe('chatHelpers', () => {
|
|
74
74
|
] as ChatMessage[];
|
75
75
|
|
76
76
|
it('returns all messages if history is disabled', () => {
|
77
|
-
const config = { enableHistoryCount: false, historyCount:
|
77
|
+
const config = { enableHistoryCount: false, historyCount: undefined } as LobeAgentChatConfig;
|
78
78
|
const slicedMessages = chatHelpers.getSlicedMessagesWithConfig(messages, config);
|
79
79
|
expect(slicedMessages).toEqual(messages);
|
80
80
|
});
|
@@ -105,5 +105,11 @@ describe('chatHelpers', () => {
|
|
105
105
|
const slicedMessages = chatHelpers.getSlicedMessagesWithConfig([], config);
|
106
106
|
expect(slicedMessages).toEqual([]);
|
107
107
|
});
|
108
|
+
|
109
|
+
it('returns an empty array when historyCount is zero', () => {
|
110
|
+
const config = { enableHistoryCount: true, historyCount: 0 } as LobeAgentChatConfig;
|
111
|
+
const slicedMessages = chatHelpers.getSlicedMessagesWithConfig(messages, config);
|
112
|
+
expect(slicedMessages).toEqual([]);
|
113
|
+
});
|
108
114
|
});
|
109
115
|
});
|
@@ -14,13 +14,13 @@ const getSlicedMessagesWithConfig = (
|
|
14
14
|
config: LobeAgentChatConfig,
|
15
15
|
includeNewUserMessage?: boolean,
|
16
16
|
): ChatMessage[] => {
|
17
|
-
// if historyCount is not enabled
|
18
|
-
if (!config.enableHistoryCount ||
|
17
|
+
// if historyCount is not enabled, return all messages
|
18
|
+
if (!config.enableHistoryCount || config.historyCount === undefined) return messages;
|
19
19
|
|
20
20
|
// if user send message, history will include this message so the total length should +1
|
21
21
|
const messagesCount = !!includeNewUserMessage ? config.historyCount + 1 : config.historyCount;
|
22
22
|
|
23
|
-
// if historyCount is negative, return empty array
|
23
|
+
// if historyCount is negative or set to 0, return empty array
|
24
24
|
if (messagesCount <= 0) return [];
|
25
25
|
|
26
26
|
// if historyCount is positive, return last N messages
|