@lobehub/chat 1.39.0 → 1.39.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
CHANGED
@@ -2,6 +2,31 @@
|
|
2
2
|
|
3
3
|
# Changelog
|
4
4
|
|
5
|
+
### [Version 1.39.1](https://github.com/lobehub/lobe-chat/compare/v1.39.0...v1.39.1)
|
6
|
+
|
7
|
+
<sup>Released on **2024-12-24**</sup>
|
8
|
+
|
9
|
+
#### 🐛 Bug Fixes
|
10
|
+
|
11
|
+
- **misc**: Fix image input on pglite.
|
12
|
+
|
13
|
+
<br/>
|
14
|
+
|
15
|
+
<details>
|
16
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
17
|
+
|
18
|
+
#### What's fixed
|
19
|
+
|
20
|
+
- **misc**: Fix image input on pglite, closes [#5167](https://github.com/lobehub/lobe-chat/issues/5167) ([5c5b37d](https://github.com/lobehub/lobe-chat/commit/5c5b37d))
|
21
|
+
|
22
|
+
</details>
|
23
|
+
|
24
|
+
<div align="right">
|
25
|
+
|
26
|
+
[](#readme-top)
|
27
|
+
|
28
|
+
</div>
|
29
|
+
|
5
30
|
## [Version 1.39.0](https://github.com/lobehub/lobe-chat/compare/v1.38.0...v1.39.0)
|
6
31
|
|
7
32
|
<sup>Released on **2024-12-23**</sup>
|
package/changelog/v1.json
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@lobehub/chat",
|
3
|
-
"version": "1.39.
|
3
|
+
"version": "1.39.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",
|
@@ -48,7 +48,9 @@ export class MessageModel {
|
|
48
48
|
// **************** Query *************** //
|
49
49
|
query = async (
|
50
50
|
{ current = 0, pageSize = 1000, sessionId, topicId }: QueryMessageParams = {},
|
51
|
-
options: {
|
51
|
+
options: {
|
52
|
+
postProcessUrl?: (path: string | null, file: { fileType: string }) => Promise<string>;
|
53
|
+
} = {},
|
52
54
|
): Promise<MessageItem[]> => {
|
53
55
|
const offset = current * pageSize;
|
54
56
|
|
@@ -130,7 +132,9 @@ export class MessageModel {
|
|
130
132
|
const relatedFileList = await Promise.all(
|
131
133
|
rawRelatedFileList.map(async (file) => ({
|
132
134
|
...file,
|
133
|
-
url: options.postProcessUrl
|
135
|
+
url: options.postProcessUrl
|
136
|
+
? await options.postProcessUrl(file.url, file as any)
|
137
|
+
: (file.url as string),
|
134
138
|
})),
|
135
139
|
);
|
136
140
|
|
@@ -5,6 +5,7 @@ import { clientDB } from '@/database/client/db';
|
|
5
5
|
import { MessageItem } from '@/database/schemas';
|
6
6
|
import { MessageModel } from '@/database/server/models/message';
|
7
7
|
import { BaseClientService } from '@/services/baseClientService';
|
8
|
+
import { clientS3Storage } from '@/services/file/ClientS3';
|
8
9
|
import {
|
9
10
|
ChatMessage,
|
10
11
|
ChatMessageError,
|
@@ -34,10 +35,20 @@ export class ClientService extends BaseClientService implements IMessageService
|
|
34
35
|
}
|
35
36
|
|
36
37
|
async getMessages(sessionId: string, topicId?: string) {
|
37
|
-
const data = await this.messageModel.query(
|
38
|
-
|
39
|
-
|
40
|
-
|
38
|
+
const data = await this.messageModel.query(
|
39
|
+
{
|
40
|
+
sessionId: this.toDbSessionId(sessionId),
|
41
|
+
topicId,
|
42
|
+
},
|
43
|
+
{
|
44
|
+
postProcessUrl: async (url, file) => {
|
45
|
+
const hash = (url as string).replace('client-s3://', '');
|
46
|
+
const base64 = await this.getBase64ByFileHash(hash);
|
47
|
+
|
48
|
+
return `data:${file.fileType};base64,${base64}`;
|
49
|
+
},
|
50
|
+
},
|
51
|
+
);
|
41
52
|
|
42
53
|
return data as unknown as ChatMessage[];
|
43
54
|
}
|
@@ -115,4 +126,11 @@ export class ClientService extends BaseClientService implements IMessageService
|
|
115
126
|
private toDbSessionId(sessionId: string | undefined) {
|
116
127
|
return sessionId === INBOX_SESSION_ID ? undefined : sessionId;
|
117
128
|
}
|
129
|
+
|
130
|
+
private async getBase64ByFileHash(hash: string) {
|
131
|
+
const fileItem = await clientS3Storage.getObject(hash);
|
132
|
+
if (!fileItem) throw new Error('file not found');
|
133
|
+
|
134
|
+
return Buffer.from(await fileItem.arrayBuffer()).toString('base64');
|
135
|
+
}
|
118
136
|
}
|