@lobehub/chat 1.36.23 → 1.36.25

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,56 @@
2
2
 
3
3
  # Changelog
4
4
 
5
+ ### [Version 1.36.25](https://github.com/lobehub/lobe-chat/compare/v1.36.24...v1.36.25)
6
+
7
+ <sup>Released on **2024-12-14**</sup>
8
+
9
+ #### 💄 Styles
10
+
11
+ - **misc**: Add new grok models.
12
+
13
+ <br/>
14
+
15
+ <details>
16
+ <summary><kbd>Improvements and Fixes</kbd></summary>
17
+
18
+ #### Styles
19
+
20
+ - **misc**: Add new grok models, closes [#5013](https://github.com/lobehub/lobe-chat/issues/5013) ([8df3212](https://github.com/lobehub/lobe-chat/commit/8df3212))
21
+
22
+ </details>
23
+
24
+ <div align="right">
25
+
26
+ [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
27
+
28
+ </div>
29
+
30
+ ### [Version 1.36.24](https://github.com/lobehub/lobe-chat/compare/v1.36.23...v1.36.24)
31
+
32
+ <sup>Released on **2024-12-14**</sup>
33
+
34
+ #### ♻ Code Refactoring
35
+
36
+ - **misc**: Refactor file Url query in message model.
37
+
38
+ <br/>
39
+
40
+ <details>
41
+ <summary><kbd>Improvements and Fixes</kbd></summary>
42
+
43
+ #### Code refactoring
44
+
45
+ - **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))
46
+
47
+ </details>
48
+
49
+ <div align="right">
50
+
51
+ [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
52
+
53
+ </div>
54
+
5
55
  ### [Version 1.36.23](https://github.com/lobehub/lobe-chat/compare/v1.36.22...v1.36.23)
6
56
 
7
57
  <sup>Released on **2024-12-13**</sup>
package/changelog/v1.json CHANGED
@@ -1,4 +1,22 @@
1
1
  [
2
+ {
3
+ "children": {
4
+ "improvements": [
5
+ "Add new grok models."
6
+ ]
7
+ },
8
+ "date": "2024-12-14",
9
+ "version": "1.36.25"
10
+ },
11
+ {
12
+ "children": {
13
+ "improvements": [
14
+ "Refactor file Url query in message model."
15
+ ]
16
+ },
17
+ "date": "2024-12-14",
18
+ "version": "1.36.24"
19
+ },
2
20
  {
3
21
  "children": {
4
22
  "improvements": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/chat",
3
- "version": "1.36.23",
3
+ "version": "1.36.25",
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",
@@ -28,8 +28,35 @@ const XAI: ModelProviderCard = {
28
28
  tokens: 8192,
29
29
  vision: true,
30
30
  },
31
+ {
32
+ description: '该模型在准确性、指令遵循和多语言能力方面有所改进。',
33
+ displayName: 'Grok 2 1212',
34
+ enabled: true,
35
+ functionCall: true,
36
+ id: 'grok-2-1212',
37
+ pricing: {
38
+ input: 2,
39
+ output: 10,
40
+ },
41
+ releasedAt: '2024-12-12',
42
+ tokens: 131_072,
43
+ },
44
+ {
45
+ description: '该模型在准确性、指令遵循和多语言能力方面有所改进。',
46
+ displayName: 'Grok 2 Vision 1212',
47
+ enabled: true,
48
+ functionCall: true,
49
+ id: 'grok-2-vision-1212',
50
+ pricing: {
51
+ input: 2,
52
+ output: 10,
53
+ },
54
+ releasedAt: '2024-12-12',
55
+ tokens: 32_768,
56
+ vision: true,
57
+ },
31
58
  ],
32
- checkModel: 'grok-beta',
59
+ checkModel: 'grok-2-1212',
33
60
  description:
34
61
  'xAI 是一家致力于构建人工智能以加速人类科学发现的公司。我们的使命是推动我们对宇宙的共同理解。',
35
62
  id: 'xai',
@@ -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: expect.stringContaining('/abc') },
220
- { alt: 'file-3', id: 'f-3', url: expect.stringContaining('/abc') },
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
- pageSize = 1000,
53
- sessionId,
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 getFullFileUrl(file.url),
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 }) => {