@lobehub/chat 1.36.31 โ 1.36.33
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 +50 -0
- package/changelog/v1.json +18 -0
- package/docs/self-hosting/environment-variables/model-provider.mdx +7 -0
- package/docs/self-hosting/environment-variables/model-provider.zh-CN.mdx +7 -0
- package/docs/self-hosting/server-database/dokploy.zh-CN.mdx +12 -12
- package/package.json +1 -1
- package/src/config/modelProviders/github.ts +19 -10
- package/src/database/repositories/dataImporter/__tests__/index.test.ts +11 -18
- package/src/database/repositories/dataImporter/index.ts +31 -46
- package/src/database/server/models/__tests__/_test_template.ts +1 -1
- package/src/database/server/models/__tests__/agent.test.ts +1 -1
- package/src/database/server/models/__tests__/asyncTask.test.ts +1 -1
- package/src/database/server/models/__tests__/chunk.test.ts +1 -1
- package/src/database/server/models/__tests__/file.test.ts +1 -1
- package/src/database/server/models/__tests__/knowledgeBase.test.ts +1 -2
- package/src/database/server/models/__tests__/message.test.ts +35 -72
- package/src/database/server/models/__tests__/nextauth.test.ts +1 -1
- package/src/database/server/models/__tests__/session.test.ts +1 -1
- package/src/database/server/models/__tests__/sessionGroup.test.ts +1 -2
- package/src/database/server/models/__tests__/topic.test.ts +1 -1
- package/src/database/server/models/__tests__/user.test.ts +1 -1
- package/src/database/server/models/_template.ts +2 -2
- package/src/database/server/models/agent.ts +17 -25
- package/src/database/server/models/asyncTask.ts +2 -2
- package/src/database/server/models/chunk.ts +14 -14
- package/src/database/server/models/embedding.ts +1 -1
- package/src/database/server/models/file.ts +8 -10
- package/src/database/server/models/knowledgeBase.ts +4 -6
- package/src/database/server/models/message.ts +54 -65
- package/src/database/server/models/plugin.ts +2 -2
- package/src/database/server/models/ragEval/dataset.ts +2 -2
- package/src/database/server/models/ragEval/datasetRecord.ts +3 -8
- package/src/database/server/models/ragEval/evaluation.ts +3 -2
- package/src/database/server/models/ragEval/evaluationRecord.ts +2 -2
- package/src/database/server/models/session.ts +38 -35
- package/src/database/server/models/sessionGroup.ts +4 -4
- package/src/database/server/models/thread.ts +2 -2
- package/src/database/server/models/topic.ts +48 -53
- package/src/database/server/models/user.ts +12 -12
- package/src/libs/agent-runtime/github/index.test.ts +68 -41
- package/src/libs/agent-runtime/github/index.ts +51 -1
- package/src/libs/agent-runtime/togetherai/index.ts +2 -1
- package/src/libs/agent-runtime/utils/openaiCompatibleFactory/index.ts +10 -9
- package/src/libs/agent-runtime/utils/streams/azureOpenai.test.ts +0 -1
- package/src/libs/next-auth/adapter/index.ts +1 -1
- package/src/server/routers/lambda/chunk.ts +2 -2
- package/vercel.json +1 -1
package/CHANGELOG.md
CHANGED
@@ -2,6 +2,56 @@
|
|
2
2
|
|
3
3
|
# Changelog
|
4
4
|
|
5
|
+
### [Version 1.36.33](https://github.com/lobehub/lobe-chat/compare/v1.36.32...v1.36.33)
|
6
|
+
|
7
|
+
<sup>Released on **2024-12-18**</sup>
|
8
|
+
|
9
|
+
#### ๐ Bug Fixes
|
10
|
+
|
11
|
+
- **misc**: Fix GitHub model fetch.
|
12
|
+
|
13
|
+
<br/>
|
14
|
+
|
15
|
+
<details>
|
16
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
17
|
+
|
18
|
+
#### What's fixed
|
19
|
+
|
20
|
+
- **misc**: Fix GitHub model fetch, closes [#4645](https://github.com/lobehub/lobe-chat/issues/4645) ([b69dce3](https://github.com/lobehub/lobe-chat/commit/b69dce3))
|
21
|
+
|
22
|
+
</details>
|
23
|
+
|
24
|
+
<div align="right">
|
25
|
+
|
26
|
+
[](#readme-top)
|
27
|
+
|
28
|
+
</div>
|
29
|
+
|
30
|
+
### [Version 1.36.32](https://github.com/lobehub/lobe-chat/compare/v1.36.31...v1.36.32)
|
31
|
+
|
32
|
+
<sup>Released on **2024-12-17**</sup>
|
33
|
+
|
34
|
+
#### โป Code Refactoring
|
35
|
+
|
36
|
+
- **misc**: Refactor the drizzle code style.
|
37
|
+
|
38
|
+
<br/>
|
39
|
+
|
40
|
+
<details>
|
41
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
42
|
+
|
43
|
+
#### Code refactoring
|
44
|
+
|
45
|
+
- **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))
|
46
|
+
|
47
|
+
</details>
|
48
|
+
|
49
|
+
<div align="right">
|
50
|
+
|
51
|
+
[](#readme-top)
|
52
|
+
|
53
|
+
</div>
|
54
|
+
|
5
55
|
### [Version 1.36.31](https://github.com/lobehub/lobe-chat/compare/v1.36.30...v1.36.31)
|
6
56
|
|
7
57
|
<sup>Released on **2024-12-17**</sup>
|
package/changelog/v1.json
CHANGED
@@ -1,4 +1,22 @@
|
|
1
1
|
[
|
2
|
+
{
|
3
|
+
"children": {
|
4
|
+
"fixes": [
|
5
|
+
"Fix GitHub model fetch."
|
6
|
+
]
|
7
|
+
},
|
8
|
+
"date": "2024-12-18",
|
9
|
+
"version": "1.36.33"
|
10
|
+
},
|
11
|
+
{
|
12
|
+
"children": {
|
13
|
+
"improvements": [
|
14
|
+
"Refactor the drizzle code style."
|
15
|
+
]
|
16
|
+
},
|
17
|
+
"date": "2024-12-17",
|
18
|
+
"version": "1.36.32"
|
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.
|
3
|
+
"version": "1.36.33",
|
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",
|
@@ -15,7 +15,8 @@ const Github: ModelProviderCard = {
|
|
15
15
|
vision: true,
|
16
16
|
},
|
17
17
|
{
|
18
|
-
description:
|
18
|
+
description:
|
19
|
+
'ไธๆณจไบ้ซ็บงๆจ็ๅ่งฃๅณๅคๆ้ฎ้ข๏ผๅ
ๆฌๆฐๅญฆๅ็งๅญฆไปปๅกใ้ๅธธ้ๅ้่ฆๆทฑๅบฆไธไธๆ็่งฃๅ่ชไธปๅทฅไฝๆต็จ็ๅบ็จใ',
|
19
20
|
displayName: 'OpenAI o1-preview',
|
20
21
|
enabled: true,
|
21
22
|
functionCall: false,
|
@@ -45,7 +46,8 @@ const Github: ModelProviderCard = {
|
|
45
46
|
vision: true,
|
46
47
|
},
|
47
48
|
{
|
48
|
-
description:
|
49
|
+
description:
|
50
|
+
'ไธไธช52Bๅๆฐ๏ผ12Bๆดป่ท๏ผ็ๅค่ฏญ่จๆจกๅ๏ผๆไพ256K้ฟไธไธๆ็ชๅฃใๅฝๆฐ่ฐ็จใ็ปๆๅ่พๅบๅๅบไบไบๅฎ็็ๆใ',
|
49
51
|
displayName: 'AI21 Jamba 1.5 Mini',
|
50
52
|
functionCall: true,
|
51
53
|
id: 'ai21-jamba-1.5-mini',
|
@@ -53,7 +55,8 @@ const Github: ModelProviderCard = {
|
|
53
55
|
tokens: 262_144,
|
54
56
|
},
|
55
57
|
{
|
56
|
-
description:
|
58
|
+
description:
|
59
|
+
'ไธไธช398Bๅๆฐ๏ผ94Bๆดป่ท๏ผ็ๅค่ฏญ่จๆจกๅ๏ผๆไพ256K้ฟไธไธๆ็ชๅฃใๅฝๆฐ่ฐ็จใ็ปๆๅ่พๅบๅๅบไบไบๅฎ็็ๆใ',
|
57
60
|
displayName: 'AI21 Jamba 1.5 Large',
|
58
61
|
functionCall: true,
|
59
62
|
id: 'ai21-jamba-1.5-large',
|
@@ -61,7 +64,8 @@ const Github: ModelProviderCard = {
|
|
61
64
|
tokens: 262_144,
|
62
65
|
},
|
63
66
|
{
|
64
|
-
description:
|
67
|
+
description:
|
68
|
+
'Command Rๆฏไธไธชๅฏๆฉๅฑ็็ๆๆจกๅ๏ผๆจๅจ้ๅฏนRAGๅๅทฅๅ
ทไฝฟ็จ๏ผไฝฟไผไธ่ฝๅคๅฎ็ฐ็ไบง็บงAIใ',
|
65
69
|
displayName: 'Cohere Command R',
|
66
70
|
id: 'cohere-command-r',
|
67
71
|
maxOutput: 4096,
|
@@ -75,7 +79,8 @@ const Github: ModelProviderCard = {
|
|
75
79
|
tokens: 131_072,
|
76
80
|
},
|
77
81
|
{
|
78
|
-
description:
|
82
|
+
description:
|
83
|
+
'Mistral Nemoๆฏไธ็งๅฐ็ซฏ็่ฏญ่จๆจกๅ๏ผLLM๏ผ๏ผๅจๅ
ถๅฐบๅฏธ็ฑปๅซไธญๆฅๆๆๅ
่ฟ็ๆจ็ใไธ็็ฅ่ฏๅ็ผ็ ่ฝๅใ',
|
79
84
|
displayName: 'Mistral Nemo',
|
80
85
|
id: 'mistral-nemo',
|
81
86
|
maxOutput: 4096,
|
@@ -89,7 +94,8 @@ const Github: ModelProviderCard = {
|
|
89
94
|
tokens: 131_072,
|
90
95
|
},
|
91
96
|
{
|
92
|
-
description:
|
97
|
+
description:
|
98
|
+
'Mistral็ๆ่ฐๆจกๅ๏ผ้ๅ้่ฆๅคง่งๆจกๆจ็่ฝๅๆ้ซๅบฆไธไธๅ็ๅคๆไปปๅก๏ผๅๆๆๆฌ็ๆใไปฃ็ ็ๆใRAGๆไปฃ็๏ผใ',
|
93
99
|
displayName: 'Mistral Large',
|
94
100
|
id: 'mistral-large',
|
95
101
|
maxOutput: 4096,
|
@@ -112,21 +118,24 @@ const Github: ModelProviderCard = {
|
|
112
118
|
vision: true,
|
113
119
|
},
|
114
120
|
{
|
115
|
-
description:
|
121
|
+
description:
|
122
|
+
'Llama 3.1ๆไปค่ฐไผ็ๆๆฌๆจกๅ๏ผ้ๅฏนๅค่ฏญ่จๅฏน่ฏ็จไพ่ฟ่กไบไผๅ๏ผๅจ่ฎธๅคๅฏ็จ็ๅผๆบๅๅฐ้ญ่ๅคฉๆจกๅไธญ๏ผๅจๅธธ่ง่กไธๅบๅไธ่กจ็ฐไผๅผใ',
|
116
123
|
displayName: 'Meta Llama 3.1 8B',
|
117
124
|
id: 'meta-llama-3.1-8b-instruct',
|
118
125
|
maxOutput: 4096,
|
119
126
|
tokens: 131_072,
|
120
127
|
},
|
121
128
|
{
|
122
|
-
description:
|
129
|
+
description:
|
130
|
+
'Llama 3.1ๆไปค่ฐไผ็ๆๆฌๆจกๅ๏ผ้ๅฏนๅค่ฏญ่จๅฏน่ฏ็จไพ่ฟ่กไบไผๅ๏ผๅจ่ฎธๅคๅฏ็จ็ๅผๆบๅๅฐ้ญ่ๅคฉๆจกๅไธญ๏ผๅจๅธธ่ง่กไธๅบๅไธ่กจ็ฐไผๅผใ',
|
123
131
|
displayName: 'Meta Llama 3.1 70B',
|
124
132
|
id: 'meta-llama-3.1-70b-instruct',
|
125
133
|
maxOutput: 4096,
|
126
134
|
tokens: 131_072,
|
127
135
|
},
|
128
136
|
{
|
129
|
-
description:
|
137
|
+
description:
|
138
|
+
'Llama 3.1ๆไปค่ฐไผ็ๆๆฌๆจกๅ๏ผ้ๅฏนๅค่ฏญ่จๅฏน่ฏ็จไพ่ฟ่กไบไผๅ๏ผๅจ่ฎธๅคๅฏ็จ็ๅผๆบๅๅฐ้ญ่ๅคฉๆจกๅไธญ๏ผๅจๅธธ่ง่กไธๅบๅไธ่กจ็ฐไผๅผใ',
|
130
139
|
displayName: 'Meta Llama 3.1 405B',
|
131
140
|
id: 'meta-llama-3.1-405b-instruct',
|
132
141
|
maxOutput: 4096,
|
@@ -209,7 +218,7 @@ const Github: ModelProviderCard = {
|
|
209
218
|
description: '้่ฟGitHubๆจกๅ๏ผๅผๅไบบๅๅฏไปฅๆไธบAIๅทฅ็จๅธ๏ผๅนถไฝฟ็จ่กไธ้ขๅ
็AIๆจกๅ่ฟ่กๆๅปบใ',
|
210
219
|
enabled: true,
|
211
220
|
id: 'github',
|
212
|
-
|
221
|
+
modelList: { showModelFetcher: true }, // I'm not sure if it is good to show the model fetcher, as remote list is not complete.
|
213
222
|
name: 'GitHub',
|
214
223
|
url: 'https://github.com/marketplace/models',
|
215
224
|
};
|
@@ -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 })
|
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
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
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 {
|
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
|
-
.
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
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)
|
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
|
-
|
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
|
-
.
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
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
|
-
.
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
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, 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';
|