@lobehub/chat 0.150.4 → 0.150.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 +25 -0
- package/package.json +1 -1
- package/src/app/chat/features/SessionSearchBar/index.tsx +3 -7
- package/src/database/client/models/session.ts +5 -5
- package/src/server/routers/config/parseDefaultAgent.test.ts +14 -0
- package/src/server/routers/config/parseDefaultAgent.ts +5 -0
- package/src/store/agent/slices/chat/__snapshots__/selectors.test.ts.snap +1 -1
- package/src/store/session/slices/session/action.ts +9 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,31 @@
|
|
|
2
2
|
|
|
3
3
|
# Changelog
|
|
4
4
|
|
|
5
|
+
### [Version 0.150.5](https://github.com/lobehub/lobe-chat/compare/v0.150.4...v0.150.5)
|
|
6
|
+
|
|
7
|
+
<sup>Released on **2024-04-27**</sup>
|
|
8
|
+
|
|
9
|
+
#### 🐛 Bug Fixes
|
|
10
|
+
|
|
11
|
+
- **misc**: Fix the plugin string env and search error.
|
|
12
|
+
|
|
13
|
+
<br/>
|
|
14
|
+
|
|
15
|
+
<details>
|
|
16
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
|
17
|
+
|
|
18
|
+
#### What's fixed
|
|
19
|
+
|
|
20
|
+
- **misc**: Fix the plugin string env and search error, closes [#2239](https://github.com/lobehub/lobe-chat/issues/2239) ([74b1ae0](https://github.com/lobehub/lobe-chat/commit/74b1ae0))
|
|
21
|
+
|
|
22
|
+
</details>
|
|
23
|
+
|
|
24
|
+
<div align="right">
|
|
25
|
+
|
|
26
|
+
[](#readme-top)
|
|
27
|
+
|
|
28
|
+
</div>
|
|
29
|
+
|
|
5
30
|
### [Version 0.150.4](https://github.com/lobehub/lobe-chat/compare/v0.150.3...v0.150.4)
|
|
6
31
|
|
|
7
32
|
<sup>Released on **2024-04-27**</sup>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lobehub/chat",
|
|
3
|
-
"version": "0.150.
|
|
3
|
+
"version": "0.150.5",
|
|
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",
|
|
@@ -8,9 +8,10 @@ import { useSessionStore } from '@/store/session';
|
|
|
8
8
|
const SessionSearchBar = memo<{ mobile?: boolean }>(({ mobile: controlledMobile }) => {
|
|
9
9
|
const { t } = useTranslation('chat');
|
|
10
10
|
|
|
11
|
-
const [keywords, useSearchSessions] = useSessionStore((s) => [
|
|
11
|
+
const [keywords, useSearchSessions, updateSearchKeywords] = useSessionStore((s) => [
|
|
12
12
|
s.sessionSearchKeywords,
|
|
13
13
|
s.useSearchSessions,
|
|
14
|
+
s.updateSearchKeywords,
|
|
14
15
|
]);
|
|
15
16
|
|
|
16
17
|
const { isValidating } = useSearchSessions(keywords);
|
|
@@ -24,12 +25,7 @@ const SessionSearchBar = memo<{ mobile?: boolean }>(({ mobile: controlledMobile
|
|
|
24
25
|
enableShortKey={!mobile}
|
|
25
26
|
loading={isValidating}
|
|
26
27
|
onChange={(e) => {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
useSessionStore.setState({
|
|
30
|
-
isSearching: !!newKeywords,
|
|
31
|
-
sessionSearchKeywords: newKeywords,
|
|
32
|
-
});
|
|
28
|
+
updateSearchKeywords(e.target.value);
|
|
33
29
|
}}
|
|
34
30
|
placeholder={t('searchAgentPlaceholder')}
|
|
35
31
|
shortKey={'k'}
|
|
@@ -81,15 +81,15 @@ class _SessionModel extends BaseModel {
|
|
|
81
81
|
async queryByKeyword(keyword: string): Promise<LobeSessions> {
|
|
82
82
|
if (!keyword) return [];
|
|
83
83
|
|
|
84
|
-
|
|
84
|
+
const startTime = Date.now();
|
|
85
85
|
const keywordLowerCase = keyword.toLowerCase();
|
|
86
86
|
|
|
87
87
|
// First, filter sessions by title and description
|
|
88
88
|
const matchingSessionsPromise = this.table
|
|
89
89
|
.filter((session) => {
|
|
90
90
|
return (
|
|
91
|
-
session.meta.title
|
|
92
|
-
session.meta.description
|
|
91
|
+
session.meta.title?.toLowerCase().includes(keywordLowerCase) ||
|
|
92
|
+
session.meta.description?.toLowerCase().includes(keywordLowerCase)
|
|
93
93
|
);
|
|
94
94
|
})
|
|
95
95
|
.toArray();
|
|
@@ -112,7 +112,7 @@ class _SessionModel extends BaseModel {
|
|
|
112
112
|
// match topics
|
|
113
113
|
const matchingTopicsPromise = this.db.topics
|
|
114
114
|
.filter((topic) => {
|
|
115
|
-
return topic.title
|
|
115
|
+
return topic.title?.toLowerCase().includes(keywordLowerCase);
|
|
116
116
|
})
|
|
117
117
|
.toArray();
|
|
118
118
|
|
|
@@ -139,7 +139,7 @@ class _SessionModel extends BaseModel {
|
|
|
139
139
|
.anyOf([...combinedSessionIds])
|
|
140
140
|
.toArray();
|
|
141
141
|
|
|
142
|
-
console.
|
|
142
|
+
console.log(`检索到 ${items.length} 项,耗时 ${Date.now() - startTime}ms`);
|
|
143
143
|
return this.mapToAgentSessions(items);
|
|
144
144
|
}
|
|
145
145
|
|
|
@@ -110,6 +110,20 @@ describe('parseAgentConfig', () => {
|
|
|
110
110
|
};
|
|
111
111
|
expect(parseAgentConfig(envStr)).toEqual(expected);
|
|
112
112
|
});
|
|
113
|
+
|
|
114
|
+
it('should parsers plugins correctly', () => {
|
|
115
|
+
const envStr =
|
|
116
|
+
'enableAutoCreateTopic=true;model=gemini-pro;provider=google;plugins=lobe-image-designer';
|
|
117
|
+
|
|
118
|
+
const expected = {
|
|
119
|
+
enableAutoCreateTopic: true,
|
|
120
|
+
model: 'gemini-pro',
|
|
121
|
+
plugins: ['lobe-image-designer'],
|
|
122
|
+
provider: 'google',
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
expect(parseAgentConfig(envStr)).toEqual(expected);
|
|
126
|
+
});
|
|
113
127
|
});
|
|
114
128
|
|
|
115
129
|
describe('Error Boundary', () => {
|
|
@@ -35,6 +35,11 @@ export const parseAgentConfig = (envStr: string) => {
|
|
|
35
35
|
finalValue = array.map((item) => (isNaN(item as any) ? item : Number(item)));
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
// handle plugins if it's a string
|
|
39
|
+
if (key === 'plugins') {
|
|
40
|
+
finalValue = typeof finalValue === 'string' ? [finalValue] : finalValue;
|
|
41
|
+
}
|
|
42
|
+
|
|
38
43
|
set(config, key, finalValue);
|
|
39
44
|
}
|
|
40
45
|
|
|
@@ -70,6 +70,8 @@ export interface SessionAction {
|
|
|
70
70
|
*/
|
|
71
71
|
removeSession: (id: string) => Promise<void>;
|
|
72
72
|
|
|
73
|
+
updateSearchKeywords: (keywords: string) => void;
|
|
74
|
+
|
|
73
75
|
useFetchSessions: () => SWRResponse<ChatSessionList>;
|
|
74
76
|
useSearchSessions: (keyword?: string) => SWRResponse<any>;
|
|
75
77
|
|
|
@@ -169,6 +171,13 @@ export const createSessionSlice: StateCreator<
|
|
|
169
171
|
}
|
|
170
172
|
},
|
|
171
173
|
|
|
174
|
+
updateSearchKeywords: (keywords) => {
|
|
175
|
+
set(
|
|
176
|
+
{ isSearching: !!keywords, sessionSearchKeywords: keywords },
|
|
177
|
+
false,
|
|
178
|
+
n('updateSearchKeywords'),
|
|
179
|
+
);
|
|
180
|
+
},
|
|
172
181
|
updateSessionGroupId: async (sessionId, group) => {
|
|
173
182
|
await get().internal_updateSession(sessionId, { group });
|
|
174
183
|
},
|