@lobehub/chat 1.32.0 → 1.32.1
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 +33 -0
- package/package.json +1 -1
- package/src/database/server/models/__tests__/session.test.ts +38 -4
- package/src/database/server/models/session.ts +43 -10
- package/src/database/server/models/topic.ts +6 -1
- package/src/libs/agent-runtime/github/index.ts +1 -1
- package/src/libs/agent-runtime/openai/index.ts +0 -1
- package/src/store/chat/slices/topic/selectors.ts +1 -1
package/CHANGELOG.md
CHANGED
@@ -2,6 +2,39 @@
|
|
2
2
|
|
3
3
|
# Changelog
|
4
4
|
|
5
|
+
### [Version 1.32.1](https://github.com/lobehub/lobe-chat/compare/v1.32.0...v1.32.1)
|
6
|
+
|
7
|
+
<sup>Released on **2024-11-19**</sup>
|
8
|
+
|
9
|
+
#### 🐛 Bug Fixes
|
10
|
+
|
11
|
+
- **misc**: Keyword search for chat history & sessions.
|
12
|
+
|
13
|
+
#### 💄 Styles
|
14
|
+
|
15
|
+
- **misc**: Support o1 models using streaming.
|
16
|
+
|
17
|
+
<br/>
|
18
|
+
|
19
|
+
<details>
|
20
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
21
|
+
|
22
|
+
#### What's fixed
|
23
|
+
|
24
|
+
- **misc**: Keyword search for chat history & sessions, closes [#4725](https://github.com/lobehub/lobe-chat/issues/4725) ([415d772](https://github.com/lobehub/lobe-chat/commit/415d772))
|
25
|
+
|
26
|
+
#### Styles
|
27
|
+
|
28
|
+
- **misc**: Support o1 models using streaming, closes [#4732](https://github.com/lobehub/lobe-chat/issues/4732) ([7e9e71a](https://github.com/lobehub/lobe-chat/commit/7e9e71a))
|
29
|
+
|
30
|
+
</details>
|
31
|
+
|
32
|
+
<div align="right">
|
33
|
+
|
34
|
+
[](#readme-top)
|
35
|
+
|
36
|
+
</div>
|
37
|
+
|
5
38
|
## [Version 1.32.0](https://github.com/lobehub/lobe-chat/compare/v1.31.11...v1.32.0)
|
6
39
|
|
7
40
|
<sup>Released on **2024-11-19**</sup>
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@lobehub/chat",
|
3
|
-
"version": "1.32.
|
3
|
+
"version": "1.32.1",
|
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",
|
@@ -231,8 +231,18 @@ describe('SessionModel', () => {
|
|
231
231
|
|
232
232
|
it('should return sessions with matching title', async () => {
|
233
233
|
await serverDB.insert(sessions).values([
|
234
|
-
{ id: '1', userId
|
235
|
-
{ id: '2', userId
|
234
|
+
{ id: '1', userId },
|
235
|
+
{ id: '2', userId },
|
236
|
+
]);
|
237
|
+
|
238
|
+
await serverDB.insert(agents).values([
|
239
|
+
{ id: 'agent-1', userId, model: 'gpt-3.5-turbo', title: 'Hello, Agent 1' },
|
240
|
+
{ id: 'agent-2', userId, model: 'gpt-4', title: 'Agent 2' },
|
241
|
+
]);
|
242
|
+
|
243
|
+
await serverDB.insert(agentsToSessions).values([
|
244
|
+
{ agentId: 'agent-1', sessionId: '1' },
|
245
|
+
{ agentId: 'agent-2', sessionId: '2' },
|
236
246
|
]);
|
237
247
|
|
238
248
|
const result = await sessionModel.queryByKeyword('hello');
|
@@ -241,9 +251,21 @@ describe('SessionModel', () => {
|
|
241
251
|
});
|
242
252
|
|
243
253
|
it('should return sessions with matching description', async () => {
|
254
|
+
// The sessions has no title and desc,
|
255
|
+
// see: https://github.com/lobehub/lobe-chat/pull/4725
|
244
256
|
await serverDB.insert(sessions).values([
|
245
|
-
{ id: '1', userId
|
246
|
-
{ id: '2', userId
|
257
|
+
{ id: '1', userId },
|
258
|
+
{ id: '2', userId },
|
259
|
+
]);
|
260
|
+
|
261
|
+
await serverDB.insert(agents).values([
|
262
|
+
{ id: 'agent-1', userId, model: 'gpt-3.5-turbo', title: 'Agent 1', description: 'Description with Keyword' },
|
263
|
+
{ id: 'agent-2', userId, model: 'gpt-4', title: 'Agent 2' },
|
264
|
+
]);
|
265
|
+
|
266
|
+
await serverDB.insert(agentsToSessions).values([
|
267
|
+
{ agentId: 'agent-1', sessionId: '1' },
|
268
|
+
{ agentId: 'agent-2', sessionId: '2' },
|
247
269
|
]);
|
248
270
|
|
249
271
|
const result = await sessionModel.queryByKeyword('keyword');
|
@@ -253,11 +275,23 @@ describe('SessionModel', () => {
|
|
253
275
|
|
254
276
|
it('should return sessions with matching title or description', async () => {
|
255
277
|
await serverDB.insert(sessions).values([
|
278
|
+
{ id: '1', userId },
|
279
|
+
{ id: '2', userId },
|
280
|
+
{ id: '3', userId },
|
281
|
+
]);
|
282
|
+
|
283
|
+
await serverDB.insert(agents).values([
|
256
284
|
{ id: '1', userId, title: 'Title with keyword', description: 'Some description' },
|
257
285
|
{ id: '2', userId, title: 'Another Session', description: 'Description with keyword' },
|
258
286
|
{ id: '3', userId, title: 'Third Session', description: 'Third description' },
|
259
287
|
]);
|
260
288
|
|
289
|
+
await serverDB.insert(agentsToSessions).values([
|
290
|
+
{ agentId: '1', sessionId: '1' },
|
291
|
+
{ agentId: '2', sessionId: '2' },
|
292
|
+
{ agentId: '3', sessionId: '3' },
|
293
|
+
]);
|
294
|
+
|
261
295
|
const result = await sessionModel.queryByKeyword('keyword');
|
262
296
|
expect(result).toHaveLength(2);
|
263
297
|
expect(result.map((s) => s.id)).toEqual(['1', '2']);
|
@@ -61,7 +61,7 @@ export class SessionModel {
|
|
61
61
|
|
62
62
|
const keywordLowerCase = keyword.toLowerCase();
|
63
63
|
|
64
|
-
const data = await this.
|
64
|
+
const data = await this.findSessionsByKeywords({ keyword: keywordLowerCase });
|
65
65
|
|
66
66
|
return data.map((item) => this.mapSessionItem(item as any));
|
67
67
|
}
|
@@ -281,15 +281,15 @@ export class SessionModel {
|
|
281
281
|
pinned !== undefined ? eq(sessions.pinned, pinned) : eq(sessions.userId, this.userId),
|
282
282
|
keyword
|
283
283
|
? or(
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
284
|
+
like(
|
285
|
+
sql`lower(${sessions.title})` as unknown as Column,
|
286
|
+
`%${keyword.toLowerCase()}%`,
|
287
|
+
),
|
288
|
+
like(
|
289
|
+
sql`lower(${sessions.description})` as unknown as Column,
|
290
|
+
`%${keyword.toLowerCase()}%`,
|
291
|
+
),
|
292
|
+
)
|
293
293
|
: eq(sessions.userId, this.userId),
|
294
294
|
group ? eq(sessions.groupId, group) : isNull(sessions.groupId),
|
295
295
|
),
|
@@ -297,4 +297,37 @@ export class SessionModel {
|
|
297
297
|
with: { agentsToSessions: { columns: {}, with: { agent: true } }, group: true },
|
298
298
|
});
|
299
299
|
}
|
300
|
+
|
301
|
+
async findSessionsByKeywords(params: {
|
302
|
+
current?: number;
|
303
|
+
keyword: string;
|
304
|
+
pageSize?: number;
|
305
|
+
}) {
|
306
|
+
const { keyword, pageSize = 9999, current = 0 } = params;
|
307
|
+
const offset = current * pageSize;
|
308
|
+
const results = await serverDB.query.agents.findMany({
|
309
|
+
limit: pageSize,
|
310
|
+
offset,
|
311
|
+
orderBy: [desc(agents.updatedAt)],
|
312
|
+
where: and(
|
313
|
+
eq(agents.userId, this.userId),
|
314
|
+
or(
|
315
|
+
like(
|
316
|
+
sql`lower(${agents.title})` as unknown as Column,
|
317
|
+
`%${keyword.toLowerCase()}%`,
|
318
|
+
),
|
319
|
+
like(
|
320
|
+
sql`lower(${agents.description})` as unknown as Column,
|
321
|
+
`%${keyword.toLowerCase()}%`,
|
322
|
+
),
|
323
|
+
)
|
324
|
+
),
|
325
|
+
with: { agentsToSessions: { columns: {}, with: { session: true } } },
|
326
|
+
});
|
327
|
+
try {
|
328
|
+
// @ts-expect-error
|
329
|
+
return results.map((item) => item.agentsToSessions[0].session);
|
330
|
+
} catch {}
|
331
|
+
return []
|
332
|
+
}
|
300
333
|
}
|
@@ -85,7 +85,12 @@ export class TopicModel {
|
|
85
85
|
serverDB
|
86
86
|
.select()
|
87
87
|
.from(messages)
|
88
|
-
.where(
|
88
|
+
.where(
|
89
|
+
and(
|
90
|
+
eq(messages.topicId, topics.id),
|
91
|
+
matchKeyword(messages.content)
|
92
|
+
)
|
93
|
+
),
|
89
94
|
),
|
90
95
|
),
|
91
96
|
),
|
@@ -10,7 +10,7 @@ export const LobeGithubAI = LobeOpenAICompatibleFactory({
|
|
10
10
|
const { model } = payload;
|
11
11
|
|
12
12
|
if (o1Models.has(model)) {
|
13
|
-
return pruneO1Payload(payload) as any;
|
13
|
+
return { ...pruneO1Payload(payload), stream: false } as any;
|
14
14
|
}
|
15
15
|
|
16
16
|
return { ...payload, stream: payload.stream ?? true };
|
@@ -42,7 +42,7 @@ const currentActiveTopicSummary = (s: ChatStoreState): ChatTopicSummary | undefi
|
|
42
42
|
const isCreatingTopic = (s: ChatStoreState) => s.creatingTopic;
|
43
43
|
|
44
44
|
const groupedTopicsSelector = (s: ChatStoreState): GroupedTopic[] => {
|
45
|
-
const topics =
|
45
|
+
const topics = displayTopics(s);
|
46
46
|
|
47
47
|
if (!topics) return [];
|
48
48
|
const favTopics = currentFavTopics(s);
|