@lobehub/chat 1.36.23 → 1.36.24
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,31 @@
|
|
2
2
|
|
3
3
|
# Changelog
|
4
4
|
|
5
|
+
### [Version 1.36.24](https://github.com/lobehub/lobe-chat/compare/v1.36.23...v1.36.24)
|
6
|
+
|
7
|
+
<sup>Released on **2024-12-14**</sup>
|
8
|
+
|
9
|
+
#### ♻ Code Refactoring
|
10
|
+
|
11
|
+
- **misc**: Refactor file Url query in message model.
|
12
|
+
|
13
|
+
<br/>
|
14
|
+
|
15
|
+
<details>
|
16
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
17
|
+
|
18
|
+
#### Code refactoring
|
19
|
+
|
20
|
+
- **misc**: Refactor file Url query in message model, closes [#5019](https://github.com/lobehub/lobe-chat/issues/5019) ([edf78f4](https://github.com/lobehub/lobe-chat/commit/edf78f4))
|
21
|
+
|
22
|
+
</details>
|
23
|
+
|
24
|
+
<div align="right">
|
25
|
+
|
26
|
+
[](#readme-top)
|
27
|
+
|
28
|
+
</div>
|
29
|
+
|
5
30
|
### [Version 1.36.23](https://github.com/lobehub/lobe-chat/compare/v1.36.22...v1.36.23)
|
6
31
|
|
7
32
|
<sup>Released on **2024-12-13**</sup>
|
package/changelog/v1.json
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@lobehub/chat",
|
3
|
-
"version": "1.36.
|
3
|
+
"version": "1.36.24",
|
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",
|
@@ -209,15 +209,19 @@ describe('MessageModel', () => {
|
|
209
209
|
]);
|
210
210
|
});
|
211
211
|
|
212
|
+
const domain = 'http://abc.com';
|
212
213
|
// 调用 query 方法
|
213
|
-
const result = await messageModel.query(
|
214
|
+
const result = await messageModel.query(
|
215
|
+
{},
|
216
|
+
{ postProcessUrl: async (path) => `${domain}/${path}` },
|
217
|
+
);
|
214
218
|
|
215
219
|
// 断言结果
|
216
220
|
expect(result).toHaveLength(2);
|
217
221
|
expect(result[0].id).toBe('1');
|
218
222
|
expect(result[0].imageList).toEqual([
|
219
|
-
{ alt: 'file-1', id: 'f-0', url:
|
220
|
-
{ alt: 'file-3', id: 'f-3', url:
|
223
|
+
{ alt: 'file-1', id: 'f-0', url: `${domain}/abc` },
|
224
|
+
{ alt: 'file-3', id: 'f-3', url: `${domain}/abc` },
|
221
225
|
]);
|
222
226
|
|
223
227
|
expect(result[1].id).toBe('2');
|
@@ -3,7 +3,6 @@ import { and, asc, desc, eq, gte, inArray, isNull, like, lt } from 'drizzle-orm/
|
|
3
3
|
|
4
4
|
import { LobeChatDatabase } from '@/database/type';
|
5
5
|
import { idGenerator } from '@/database/utils/idGenerator';
|
6
|
-
import { getFullFileUrl } from '@/server/utils/files';
|
7
6
|
import {
|
8
7
|
ChatFileItem,
|
9
8
|
ChatImageItem,
|
@@ -47,12 +46,10 @@ export class MessageModel {
|
|
47
46
|
}
|
48
47
|
|
49
48
|
// **************** Query *************** //
|
50
|
-
async query(
|
51
|
-
current = 0,
|
52
|
-
|
53
|
-
|
54
|
-
topicId,
|
55
|
-
}: QueryMessageParams = {}): Promise<MessageItem[]> {
|
49
|
+
async query(
|
50
|
+
{ current = 0, pageSize = 1000, sessionId, topicId }: QueryMessageParams = {},
|
51
|
+
options: { postProcessUrl?: (path: string | null) => Promise<string> } = {},
|
52
|
+
): Promise<MessageItem[]> {
|
56
53
|
const offset = current * pageSize;
|
57
54
|
|
58
55
|
// 1. get basic messages
|
@@ -133,7 +130,7 @@ export class MessageModel {
|
|
133
130
|
const relatedFileList = await Promise.all(
|
134
131
|
rawRelatedFileList.map(async (file) => ({
|
135
132
|
...file,
|
136
|
-
url: await
|
133
|
+
url: options.postProcessUrl ? await options.postProcessUrl(file.url) : (file.url as string),
|
137
134
|
})),
|
138
135
|
);
|
139
136
|
|
@@ -1,9 +1,10 @@
|
|
1
1
|
import { z } from 'zod';
|
2
2
|
|
3
|
+
import { updateMessagePluginSchema } from '@/database/schemas';
|
3
4
|
import { serverDB } from '@/database/server';
|
4
5
|
import { MessageModel } from '@/database/server/models/message';
|
5
|
-
import { updateMessagePluginSchema } from '@/database/schemas';
|
6
6
|
import { authedProcedure, publicProcedure, router } from '@/libs/trpc';
|
7
|
+
import { getFullFileUrl } from '@/server/utils/files';
|
7
8
|
import { ChatMessage } from '@/types/message';
|
8
9
|
import { BatchTaskResult } from '@/types/service';
|
9
10
|
|
@@ -70,7 +71,7 @@ export const messageRouter = router({
|
|
70
71
|
|
71
72
|
const messageModel = new MessageModel(serverDB, ctx.userId);
|
72
73
|
|
73
|
-
return messageModel.query(input);
|
74
|
+
return messageModel.query(input, { postProcessUrl: (path) => getFullFileUrl(path) });
|
74
75
|
}),
|
75
76
|
|
76
77
|
removeAllMessages: messageProcedure.mutation(async ({ ctx }) => {
|