@lobehub/chat 1.36.30 → 1.36.32

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.
Files changed (71) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/changelog/v1.json +18 -0
  3. package/docs/self-hosting/environment-variables/model-provider.mdx +7 -0
  4. package/docs/self-hosting/environment-variables/model-provider.zh-CN.mdx +7 -0
  5. package/docs/self-hosting/server-database/dokploy.zh-CN.mdx +12 -12
  6. package/package.json +1 -1
  7. package/src/app/(main)/chat/(workspace)/@conversation/features/ChatList/Content.tsx +3 -9
  8. package/src/app/(main)/chat/(workspace)/@conversation/features/ThreadHydration.tsx +2 -4
  9. package/src/app/(main)/chat/@session/features/SessionListContent/DefaultMode.tsx +2 -5
  10. package/src/app/(main)/discover/(detail)/plugin/[slug]/features/InstallPlugin.tsx +10 -15
  11. package/src/database/repositories/dataImporter/__tests__/index.test.ts +11 -18
  12. package/src/database/repositories/dataImporter/index.ts +31 -46
  13. package/src/database/server/models/__tests__/_test_template.ts +1 -1
  14. package/src/database/server/models/__tests__/agent.test.ts +1 -1
  15. package/src/database/server/models/__tests__/asyncTask.test.ts +1 -1
  16. package/src/database/server/models/__tests__/chunk.test.ts +1 -1
  17. package/src/database/server/models/__tests__/file.test.ts +1 -1
  18. package/src/database/server/models/__tests__/knowledgeBase.test.ts +1 -2
  19. package/src/database/server/models/__tests__/message.test.ts +35 -72
  20. package/src/database/server/models/__tests__/nextauth.test.ts +1 -1
  21. package/src/database/server/models/__tests__/session.test.ts +1 -1
  22. package/src/database/server/models/__tests__/sessionGroup.test.ts +1 -2
  23. package/src/database/server/models/__tests__/topic.test.ts +1 -1
  24. package/src/database/server/models/__tests__/user.test.ts +1 -1
  25. package/src/database/server/models/_template.ts +2 -2
  26. package/src/database/server/models/agent.ts +17 -25
  27. package/src/database/server/models/asyncTask.ts +2 -2
  28. package/src/database/server/models/chunk.ts +14 -14
  29. package/src/database/server/models/embedding.ts +1 -1
  30. package/src/database/server/models/file.ts +8 -10
  31. package/src/database/server/models/knowledgeBase.ts +4 -6
  32. package/src/database/server/models/message.ts +54 -65
  33. package/src/database/server/models/plugin.ts +6 -2
  34. package/src/database/server/models/ragEval/dataset.ts +2 -2
  35. package/src/database/server/models/ragEval/datasetRecord.ts +3 -8
  36. package/src/database/server/models/ragEval/evaluation.ts +3 -2
  37. package/src/database/server/models/ragEval/evaluationRecord.ts +2 -2
  38. package/src/database/server/models/session.ts +40 -35
  39. package/src/database/server/models/sessionGroup.ts +4 -4
  40. package/src/database/server/models/thread.ts +2 -2
  41. package/src/database/server/models/topic.ts +48 -53
  42. package/src/database/server/models/user.ts +12 -12
  43. package/src/features/AgentSetting/AgentPlugin/index.tsx +1 -1
  44. package/src/features/ChatInput/ActionBar/Tools/Dropdown.tsx +4 -4
  45. package/src/features/Portal/Thread/Chat/ChatList.tsx +1 -2
  46. package/src/hooks/useCheckPluginsIsInstalled.ts +10 -0
  47. package/src/hooks/useFetchInstalledPlugins.ts +10 -0
  48. package/src/hooks/useFetchMessages.ts +15 -0
  49. package/src/hooks/useFetchSessions.ts +13 -0
  50. package/src/hooks/useFetchThreads.ts +11 -0
  51. package/src/hooks/useFetchTopics.ts +6 -6
  52. package/src/layout/GlobalProvider/StoreInitialization.tsx +3 -1
  53. package/src/libs/agent-runtime/utils/streams/azureOpenai.test.ts +0 -1
  54. package/src/libs/next-auth/adapter/index.ts +1 -1
  55. package/src/server/routers/lambda/chunk.ts +2 -2
  56. package/src/services/user/client.ts +2 -2
  57. package/src/store/agent/slices/chat/action.test.ts +21 -10
  58. package/src/store/chat/slices/aiChat/actions/__tests__/generateAIChat.test.ts +10 -0
  59. package/src/store/chat/slices/builtinTool/action.ts +0 -1
  60. package/src/store/chat/slices/message/action.test.ts +3 -1
  61. package/src/store/chat/slices/message/action.ts +7 -3
  62. package/src/store/chat/slices/thread/action.ts +3 -3
  63. package/src/store/chat/slices/topic/action.test.ts +1 -1
  64. package/src/store/chat/slices/topic/action.ts +3 -3
  65. package/src/store/global/selectors.ts +6 -0
  66. package/src/store/session/slices/session/action.ts +6 -3
  67. package/src/store/session/slices/sessionGroup/action.test.ts +8 -6
  68. package/src/store/tool/slices/plugin/action.ts +5 -3
  69. package/src/store/tool/slices/store/action.ts +4 -3
  70. package/src/store/user/slices/common/action.test.ts +3 -1
  71. package/vercel.json +1 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,56 @@
2
2
 
3
3
  # Changelog
4
4
 
5
+ ### [Version 1.36.32](https://github.com/lobehub/lobe-chat/compare/v1.36.31...v1.36.32)
6
+
7
+ <sup>Released on **2024-12-17**</sup>
8
+
9
+ #### ♻ Code Refactoring
10
+
11
+ - **misc**: Refactor the drizzle code style.
12
+
13
+ <br/>
14
+
15
+ <details>
16
+ <summary><kbd>Improvements and Fixes</kbd></summary>
17
+
18
+ #### Code refactoring
19
+
20
+ - **misc**: Refactor the drizzle code style, closes [#5058](https://github.com/lobehub/lobe-chat/issues/5058) ([4057ad3](https://github.com/lobehub/lobe-chat/commit/4057ad3))
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.31](https://github.com/lobehub/lobe-chat/compare/v1.36.30...v1.36.31)
31
+
32
+ <sup>Released on **2024-12-17**</sup>
33
+
34
+ #### ♻ Code Refactoring
35
+
36
+ - **misc**: Refactor the data fetch with clientDB init check.
37
+
38
+ <br/>
39
+
40
+ <details>
41
+ <summary><kbd>Improvements and Fixes</kbd></summary>
42
+
43
+ #### Code refactoring
44
+
45
+ - **misc**: Refactor the data fetch with clientDB init check, closes [#5049](https://github.com/lobehub/lobe-chat/issues/5049) ([e6d2e09](https://github.com/lobehub/lobe-chat/commit/e6d2e09))
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.30](https://github.com/lobehub/lobe-chat/compare/v1.36.29...v1.36.30)
6
56
 
7
57
  <sup>Released on **2024-12-16**</sup>
package/changelog/v1.json CHANGED
@@ -1,4 +1,22 @@
1
1
  [
2
+ {
3
+ "children": {
4
+ "improvements": [
5
+ "Refactor the drizzle code style."
6
+ ]
7
+ },
8
+ "date": "2024-12-17",
9
+ "version": "1.36.32"
10
+ },
11
+ {
12
+ "children": {
13
+ "improvements": [
14
+ "Refactor the data fetch with clientDB init check."
15
+ ]
16
+ },
17
+ "date": "2024-12-17",
18
+ "version": "1.36.31"
19
+ },
2
20
  {
3
21
  "children": {
4
22
  "improvements": [
@@ -288,6 +288,13 @@ If you need to use Azure OpenAI to provide model services, you can refer to the
288
288
  - Default: `https://api.Perplexity.ai`
289
289
  - Example: `https://my-Perplexity-proxy.com`
290
290
 
291
+ ### `PERPLEXITY_MODEL_LIST`
292
+
293
+ - Type: Optional
294
+ - Description: Used to control the model list, use `+` to add a model, use `-` to hide a model, use `model_name=display_name` to customize the display name of a model, separated by commas. Definition syntax rules see
295
+ - Default: `-`
296
+ - Example: `-all,+llama-3.1-sonar-small-128k-online,+llama-3.1-sonar-small-128k-chat`
297
+
291
298
  ## Minimax AI
292
299
 
293
300
  ### `MINIMAX_API_KEY`
@@ -279,6 +279,13 @@ LobeChat 在部署时提供了丰富的模型服务商相关的环境变量,
279
279
  - 默认值:-
280
280
  - 示例:`pplx-xxxxxx...xxxxxx`
281
281
 
282
+ ### `PERPLEXITY_MODEL_LIST`
283
+
284
+ - 类型:可选
285
+ - 描述:用于指定自定义 Perplexity 语言模型。模型定义语法规则见 [模型列表][model-list]
286
+ - 默认值:-
287
+ - 示例: `-all,+llama-3.1-sonar-small-128k-online,+llama-3.1-sonar-small-128k-chat`
288
+
282
289
  ### `PERPLEXITY_PROXY_URL`
283
290
 
284
291
  - 类型:可选
@@ -1,15 +1,15 @@
1
- ---
2
- title: 在 Dokploy 上部署 LobeChat 的服务端数据库版本
3
- description: 本文详细介绍如何在 Dokploy 中部署服务端数据库版 LobeChat,包括数据库配置、身份验证服务配置的设置步骤。
4
- tags:
5
- - 服务端数据库
6
- - Postgres
7
- - Clerk
8
- - Dokploy部署
9
- - 数据库配置
10
- - 身份验证服务
11
- - 环境变量配置
12
- ---
1
+ ---
2
+ title: 在 Dokploy 上部署 LobeChat 的服务端数据库版本
3
+ description: 本文详细介绍如何在 Dokploy 中部署服务端数据库版 LobeChat,包括数据库配置、身份验证服务配置的设置步骤。
4
+ tags:
5
+ - 服务端数据库
6
+ - Postgres
7
+ - Clerk
8
+ - Dokploy部署
9
+ - 数据库配置
10
+ - 身份验证服务
11
+ - 环境变量配置
12
+ ---
13
13
 
14
14
  # 在 Dokploy 上部署服务端数据库版
15
15
  本文将详细介绍如何在 Dokploy 中部署服务端数据库版 LobeChat。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/chat",
3
- "version": "1.36.30",
3
+ "version": "1.36.32",
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",
@@ -3,9 +3,9 @@
3
3
  import React, { memo, useCallback } from 'react';
4
4
 
5
5
  import { SkeletonList, VirtualizedList } from '@/features/Conversation';
6
+ import { useFetchMessages } from '@/hooks/useFetchMessages';
6
7
  import { useChatStore } from '@/store/chat';
7
8
  import { chatSelectors } from '@/store/chat/selectors';
8
- import { useSessionStore } from '@/store/session';
9
9
 
10
10
  import MainChatItem from './ChatItem';
11
11
  import Welcome from './WelcomeChatItem';
@@ -15,15 +15,9 @@ interface ListProps {
15
15
  }
16
16
 
17
17
  const Content = memo<ListProps>(({ mobile }) => {
18
- const [activeTopicId, useFetchMessages, isCurrentChatLoaded] = useChatStore((s) => [
19
- s.activeTopicId,
20
- s.useFetchMessages,
21
- chatSelectors.isCurrentChatLoaded(s),
22
- ]);
23
-
24
- const [sessionId] = useSessionStore((s) => [s.activeId]);
25
- useFetchMessages(sessionId, activeTopicId);
18
+ const [isCurrentChatLoaded] = useChatStore((s) => [chatSelectors.isCurrentChatLoaded(s)]);
26
19
 
20
+ useFetchMessages();
27
21
  const data = useChatStore(chatSelectors.mainDisplayChatIDs);
28
22
 
29
23
  const itemContent = useCallback(
@@ -4,6 +4,7 @@ import { useQueryState } from 'nuqs';
4
4
  import { memo, useEffect, useLayoutEffect } from 'react';
5
5
  import { createStoreUpdater } from 'zustand-utils';
6
6
 
7
+ import { useFetchThreads } from '@/hooks/useFetchThreads';
7
8
  import { useChatStore } from '@/store/chat';
8
9
 
9
10
  // sync outside state to useChatStore
@@ -34,10 +35,7 @@ const ThreadHydration = memo(() => {
34
35
  }
35
36
  }, [portalThread]);
36
37
 
37
- const [activeTopicId, useFetchThreads] = useChatStore((s) => [
38
- s.activeTopicId,
39
- s.useFetchThreads,
40
- ]);
38
+ const activeTopicId = useChatStore((s) => s.activeTopicId);
41
39
 
42
40
  useFetchThreads(activeTopicId);
43
41
 
@@ -3,12 +3,11 @@ import isEqual from 'fast-deep-equal';
3
3
  import { memo, useMemo, useState } from 'react';
4
4
  import { useTranslation } from 'react-i18next';
5
5
 
6
+ import { useFetchSessions } from '@/hooks/useFetchSessions';
6
7
  import { useGlobalStore } from '@/store/global';
7
8
  import { systemStatusSelectors } from '@/store/global/selectors';
8
9
  import { useSessionStore } from '@/store/session';
9
10
  import { sessionSelectors } from '@/store/session/selectors';
10
- import { useUserStore } from '@/store/user';
11
- import { authSelectors } from '@/store/user/selectors';
12
11
  import { SessionDefaultGroup } from '@/types/session';
13
12
 
14
13
  import Actions from '../SessionListContent/CollapseGroup/Actions';
@@ -25,9 +24,7 @@ const DefaultMode = memo(() => {
25
24
  const [renameGroupModalOpen, setRenameGroupModalOpen] = useState(false);
26
25
  const [configGroupModalOpen, setConfigGroupModalOpen] = useState(false);
27
26
 
28
- const isLogin = useUserStore(authSelectors.isLogin);
29
- const [useFetchSessions] = useSessionStore((s) => [s.useFetchSessions]);
30
- useFetchSessions(isLogin);
27
+ useFetchSessions();
31
28
 
32
29
  const defaultSessions = useSessionStore(sessionSelectors.defaultSessions, isEqual);
33
30
  const customSessionGroups = useSessionStore(sessionSelectors.customSessionGroups, isEqual);
@@ -5,6 +5,7 @@ import { createStyles } from 'antd-style';
5
5
  import { memo, useState } from 'react';
6
6
  import { useTranslation } from 'react-i18next';
7
7
 
8
+ import { useFetchInstalledPlugins } from '@/hooks/useFetchInstalledPlugins';
8
9
  import { useToolStore } from '@/store/tool';
9
10
  import { pluginSelectors, pluginStoreSelectors } from '@/store/tool/selectors';
10
11
 
@@ -21,21 +22,15 @@ const InstallPlugin = memo<{ identifier: string }>(({ identifier }) => {
21
22
  const { t } = useTranslation(['discover', 'plugin']);
22
23
  const [loading, setLoading] = useState(false);
23
24
  const { modal } = App.useApp();
24
- const [
25
- useFetchPluginStore,
26
- useFetchInstalledPlugins,
27
- installed,
28
- installing,
29
- installPlugin,
30
- unInstallPlugin,
31
- ] = useToolStore((s) => [
32
- s.useFetchPluginStore,
33
- s.useFetchInstalledPlugins,
34
- pluginSelectors.isPluginInstalled(identifier)(s),
35
- pluginStoreSelectors.isPluginInstallLoading(identifier)(s),
36
- s.installPlugin,
37
- s.uninstallPlugin,
38
- ]);
25
+ const [useFetchPluginStore, installed, installing, installPlugin, unInstallPlugin] = useToolStore(
26
+ (s) => [
27
+ s.useFetchPluginStore,
28
+ pluginSelectors.isPluginInstalled(identifier)(s),
29
+ pluginStoreSelectors.isPluginInstallLoading(identifier)(s),
30
+ s.installPlugin,
31
+ s.uninstallPlugin,
32
+ ],
33
+ );
39
34
 
40
35
  const { isLoading } = useFetchPluginStore();
41
36
  const { isLoading: installedPluginLoading } = useFetchInstalledPlugins();
@@ -1,8 +1,7 @@
1
1
  // @vitest-environment node
2
- import { eq, inArray } from 'drizzle-orm';
2
+ import { eq, inArray } from 'drizzle-orm/expressions';
3
3
  import { beforeEach, describe, expect, it, vi } from 'vitest';
4
4
 
5
- import { getTestDBInstance } from '@/database/server/core/dbForTest';
6
5
  import {
7
6
  agents,
8
7
  agentsToSessions,
@@ -12,6 +11,7 @@ import {
12
11
  topics,
13
12
  users,
14
13
  } from '@/database/schemas';
14
+ import { getTestDBInstance } from '@/database/server/core/dbForTest';
15
15
  import { CURRENT_CONFIG_VERSION } from '@/migrations';
16
16
  import { ImporterEntryData } from '@/types/importer';
17
17
 
@@ -60,8 +60,7 @@ describe('DataImporter', () => {
60
60
  it('should skip existing session groups and return correct result', async () => {
61
61
  await serverDB
62
62
  .insert(sessionGroups)
63
- .values({ clientId: 'group1', name: 'Existing Group', userId })
64
- .execute();
63
+ .values({ clientId: 'group1', name: 'Existing Group', userId });
65
64
 
66
65
  const data: ImporterEntryData = {
67
66
  version: CURRENT_CONFIG_VERSION,
@@ -141,7 +140,7 @@ describe('DataImporter', () => {
141
140
  });
142
141
 
143
142
  it('should skip existing sessions and return correct result', async () => {
144
- await serverDB.insert(sessions).values({ clientId: 'session1', userId }).execute();
143
+ await serverDB.insert(sessions).values({ clientId: 'session1', userId });
145
144
 
146
145
  const data: ImporterEntryData = {
147
146
  version: CURRENT_CONFIG_VERSION,
@@ -477,10 +476,7 @@ describe('DataImporter', () => {
477
476
  });
478
477
 
479
478
  it('should skip existing topics and return correct result', async () => {
480
- await serverDB
481
- .insert(topics)
482
- .values({ clientId: 'topic1', title: 'Existing Topic', userId })
483
- .execute();
479
+ await serverDB.insert(topics).values({ clientId: 'topic1', title: 'Existing Topic', userId });
484
480
 
485
481
  const data: ImporterEntryData = {
486
482
  version: CURRENT_CONFIG_VERSION,
@@ -616,15 +612,12 @@ describe('DataImporter', () => {
616
612
  });
617
613
 
618
614
  it('should skip existing messages and return correct result', async () => {
619
- await serverDB
620
- .insert(messages)
621
- .values({
622
- clientId: 'msg1',
623
- content: 'Existing Message',
624
- role: 'user',
625
- userId,
626
- })
627
- .execute();
615
+ await serverDB.insert(messages).values({
616
+ clientId: 'msg1',
617
+ content: 'Existing Message',
618
+ role: 'user',
619
+ userId,
620
+ });
628
621
 
629
622
  const data: ImporterEntryData = {
630
623
  version: CURRENT_CONFIG_VERSION,
@@ -1,5 +1,5 @@
1
- import { eq, inArray, sql } from 'drizzle-orm';
2
- import { and } from 'drizzle-orm/expressions';
1
+ import { sql } from 'drizzle-orm';
2
+ import { and, eq, inArray } from 'drizzle-orm/expressions';
3
3
 
4
4
  import {
5
5
  agents,
@@ -71,8 +71,7 @@ export class DataImporterRepos {
71
71
  set: { updatedAt: new Date() },
72
72
  target: [sessionGroups.clientId, sessionGroups.userId],
73
73
  })
74
- .returning({ clientId: sessionGroups.clientId, id: sessionGroups.id })
75
- .execute();
74
+ .returning({ clientId: sessionGroups.clientId, id: sessionGroups.id });
76
75
 
77
76
  sessionGroupResult.added = mapArray.length - query.length;
78
77
 
@@ -109,8 +108,7 @@ export class DataImporterRepos {
109
108
  set: { updatedAt: new Date() },
110
109
  target: [sessions.clientId, sessions.userId],
111
110
  })
112
- .returning({ clientId: sessions.clientId, id: sessions.id })
113
- .execute();
111
+ .returning({ clientId: sessions.clientId, id: sessions.id });
114
112
 
115
113
  // get the session client-server id map
116
114
  sessionIdMap = Object.fromEntries(mapArray.map(({ clientId, id }) => [clientId, id]));
@@ -133,18 +131,14 @@ export class DataImporterRepos {
133
131
  userId: this.userId,
134
132
  })),
135
133
  )
136
- .returning({ id: agents.id })
137
- .execute();
134
+ .returning({ id: agents.id });
138
135
 
139
- await trx
140
- .insert(agentsToSessions)
141
- .values(
142
- shouldInsertSessionAgents.map(({ id }, index) => ({
143
- agentId: agentMapArray[index].id,
144
- sessionId: sessionIdMap[id],
145
- })),
146
- )
147
- .execute();
136
+ await trx.insert(agentsToSessions).values(
137
+ shouldInsertSessionAgents.map(({ id }, index) => ({
138
+ agentId: agentMapArray[index].id,
139
+ sessionId: sessionIdMap[id],
140
+ })),
141
+ );
148
142
  }
149
143
  }
150
144
 
@@ -178,8 +172,7 @@ export class DataImporterRepos {
178
172
  set: { updatedAt: new Date() },
179
173
  target: [topics.clientId, topics.userId],
180
174
  })
181
- .returning({ clientId: topics.clientId, id: topics.id })
182
- .execute();
175
+ .returning({ clientId: topics.clientId, id: topics.id });
183
176
 
184
177
  topicIdMap = Object.fromEntries(mapArray.map(({ clientId, id }) => [clientId, id]));
185
178
 
@@ -230,7 +223,7 @@ export class DataImporterRepos {
230
223
 
231
224
  for (let i = 0; i < inertValues.length; i += BATCH_SIZE) {
232
225
  const batch = inertValues.slice(i, i + BATCH_SIZE);
233
- await trx.insert(messages).values(batch).execute();
226
+ await trx.insert(messages).values(batch);
234
227
  }
235
228
 
236
229
  console.timeEnd('insert messages');
@@ -265,7 +258,7 @@ export class DataImporterRepos {
265
258
  .filter(Boolean);
266
259
 
267
260
  if (parentIdUpdates.length > 0) {
268
- const updateQuery = trx
261
+ await trx
269
262
  .update(messages)
270
263
  .set({
271
264
  parentId: sql`CASE ${sql.join(parentIdUpdates)} END`,
@@ -281,42 +274,34 @@ export class DataImporterRepos {
281
274
  // const SQL = updateQuery.toSQL();
282
275
  // console.log('sql:', SQL.sql);
283
276
  // console.log('params:', SQL.params);
284
-
285
- await updateQuery.execute();
286
277
  }
287
278
  console.timeEnd('execute updates parentId');
288
279
 
289
280
  // 4. insert message plugins
290
281
  const pluginInserts = shouldInsertMessages.filter((msg) => msg.plugin);
291
282
  if (pluginInserts.length > 0) {
292
- await trx
293
- .insert(messagePlugins)
294
- .values(
295
- pluginInserts.map((msg) => ({
296
- apiName: msg.plugin?.apiName,
297
- arguments: msg.plugin?.arguments,
298
- id: messageIdMap[msg.id],
299
- identifier: msg.plugin?.identifier,
300
- state: msg.pluginState,
301
- toolCallId: msg.tool_call_id,
302
- type: msg.plugin?.type,
303
- })),
304
- )
305
- .execute();
283
+ await trx.insert(messagePlugins).values(
284
+ pluginInserts.map((msg) => ({
285
+ apiName: msg.plugin?.apiName,
286
+ arguments: msg.plugin?.arguments,
287
+ id: messageIdMap[msg.id],
288
+ identifier: msg.plugin?.identifier,
289
+ state: msg.pluginState,
290
+ toolCallId: msg.tool_call_id,
291
+ type: msg.plugin?.type,
292
+ })),
293
+ );
306
294
  }
307
295
 
308
296
  // 5. insert message translate
309
297
  const translateInserts = shouldInsertMessages.filter((msg) => msg.extra?.translate);
310
298
  if (translateInserts.length > 0) {
311
- await trx
312
- .insert(messageTranslates)
313
- .values(
314
- translateInserts.map((msg) => ({
315
- id: messageIdMap[msg.id],
316
- ...msg.extra?.translate,
317
- })),
318
- )
319
- .execute();
299
+ await trx.insert(messageTranslates).values(
300
+ translateInserts.map((msg) => ({
301
+ id: messageIdMap[msg.id],
302
+ ...msg.extra?.translate,
303
+ })),
304
+ );
320
305
  }
321
306
 
322
307
  // TODO: 未来需要处理 TTS 和图片的插入 (目前存在 file 的部分,不方便处理)
@@ -1,5 +1,5 @@
1
1
  // @vitest-environment node
2
- import { eq } from 'drizzle-orm';
2
+ import { eq } from 'drizzle-orm/expressions';
3
3
  import { afterEach, beforeEach, describe, expect, it } from 'vitest';
4
4
 
5
5
  import { getTestDBInstance } from '@/database/server/core/dbForTest';
@@ -1,5 +1,5 @@
1
1
  // @vitest-environment node
2
- import { eq } from 'drizzle-orm';
2
+ import { eq } from 'drizzle-orm/expressions';
3
3
  import { afterEach, beforeEach, describe, expect, it } from 'vitest';
4
4
 
5
5
  import { getTestDBInstance } from '@/database/server/core/dbForTest';
@@ -1,5 +1,5 @@
1
1
  // @vitest-environment node
2
- import { eq } from 'drizzle-orm';
2
+ import { eq } from 'drizzle-orm/expressions';
3
3
  import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
4
4
 
5
5
  import { getTestDBInstance } from '@/database/server/core/dbForTest';
@@ -1,5 +1,5 @@
1
1
  // @vitest-environment node
2
- import { eq } from 'drizzle-orm';
2
+ import { eq } from 'drizzle-orm/expressions';
3
3
  import { afterEach, beforeEach, describe, expect, it } from 'vitest';
4
4
 
5
5
  import { getTestDBInstance } from '@/database/server/core/dbForTest';
@@ -1,5 +1,5 @@
1
1
  // @vitest-environment node
2
- import { eq, inArray } from 'drizzle-orm';
2
+ import { eq, inArray } from 'drizzle-orm/expressions';
3
3
  import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
4
4
 
5
5
  import { getTestDBInstance } from '@/database/server/core/dbForTest';
@@ -1,6 +1,5 @@
1
1
  // @vitest-environment node
2
- import { eq } from 'drizzle-orm';
3
- import { and, desc } from 'drizzle-orm/expressions';
2
+ import { and, eq } from 'drizzle-orm/expressions';
4
3
  import { afterEach, beforeEach, describe, expect, it } from 'vitest';
5
4
 
6
5
  import { getTestDBInstance } from '@/database/server/core/dbForTest';