@lobehub/chat 1.113.3 → 1.114.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/.eslintignore +17 -0
- package/.github/workflows/auto-i18n.yml +1 -1
- package/.github/workflows/claude.yml +1 -1
- package/.github/workflows/desktop-pr-build.yml +4 -4
- package/.github/workflows/docker-database.yml +3 -3
- package/.github/workflows/docker-pglite.yml +3 -3
- package/.github/workflows/docker.yml +3 -3
- package/.github/workflows/lighthouse.yml +2 -2
- package/.github/workflows/release-desktop-beta.yml +3 -3
- package/.github/workflows/release.yml +2 -2
- package/.github/workflows/sync-database-schema.yml +1 -1
- package/.github/workflows/sync.yml +1 -1
- package/.github/workflows/test.yml +1 -1
- package/.stylelintignore +39 -0
- package/CHANGELOG.md +50 -0
- package/changelog/v1.json +14 -0
- package/package.json +1 -1
- package/packages/const/src/index.ts +2 -0
- package/packages/model-runtime/src/RouterRuntime/createRuntime.ts +10 -5
- package/packages/model-runtime/src/openai/__snapshots__/index.test.ts.snap +29 -0
- package/packages/model-runtime/src/utils/modelParse.ts +29 -16
- package/packages/prompts/package.json +1 -0
- package/{src → packages/prompts/src}/chains/__tests__/langDetect.test.ts +1 -2
- package/{src → packages/prompts/src}/chains/__tests__/pickEmoji.test.ts +1 -2
- package/{src → packages/prompts/src}/chains/__tests__/summaryAgentName.test.ts +2 -15
- package/{src → packages/prompts/src}/chains/__tests__/summaryDescription.test.ts +2 -12
- package/{src → packages/prompts/src}/chains/__tests__/summaryHistory.test.ts +1 -5
- package/{src → packages/prompts/src}/chains/__tests__/summaryTags.test.ts +1 -14
- package/{src → packages/prompts/src}/chains/__tests__/summaryTitle.test.ts +2 -11
- package/{src → packages/prompts/src}/chains/abstractChunk.ts +2 -2
- package/{src → packages/prompts/src}/chains/answerWithContext.ts +1 -1
- package/packages/prompts/src/chains/index.ts +12 -0
- package/{src → packages/prompts/src}/chains/langDetect.ts +1 -1
- package/{src → packages/prompts/src}/chains/pickEmoji.ts +1 -1
- package/{src → packages/prompts/src}/chains/rewriteQuery.ts +2 -2
- package/{src → packages/prompts/src}/chains/summaryAgentName.ts +6 -5
- package/{src → packages/prompts/src}/chains/summaryDescription.ts +7 -5
- package/{src → packages/prompts/src}/chains/summaryGenerationTitle.ts +3 -5
- package/{src → packages/prompts/src}/chains/summaryHistory.ts +2 -3
- package/{src → packages/prompts/src}/chains/summaryTags.ts +3 -4
- package/{src → packages/prompts/src}/chains/summaryTitle.ts +5 -5
- package/{src → packages/prompts/src}/chains/translate.ts +1 -1
- package/packages/prompts/src/index.ts +2 -5
- package/packages/prompts/src/{files → prompts/files}/index.test.ts +1 -2
- package/packages/prompts/src/prompts/index.ts +5 -0
- package/packages/prompts/src/{knowledgeBaseQA → prompts/knowledgeBaseQA}/index.test.ts +1 -3
- package/packages/types/src/aiModel.ts +2 -2
- package/packages/types/src/index.ts +3 -0
- package/packages/types/src/llm.ts +3 -0
- package/src/app/[variants]/(main)/settings/provider/(detail)/[id]/index.tsx +5 -0
- package/src/app/[variants]/(main)/settings/provider/features/ProviderConfig/index.tsx +2 -4
- package/src/config/aiModels/fal.ts +26 -1
- package/src/features/AgentSetting/store/action.ts +19 -7
- package/src/server/routers/async/ragEval.ts +1 -1
- package/src/store/aiInfra/slices/aiProvider/__tests__/action.test.ts +8 -2
- package/src/store/chat/slices/aiChat/actions/memory.ts +1 -1
- package/src/store/chat/slices/aiChat/actions/rag.ts +1 -1
- package/src/store/chat/slices/thread/action.ts +3 -2
- package/src/store/chat/slices/topic/action.ts +3 -2
- package/src/store/chat/slices/translate/action.test.ts +2 -2
- package/src/store/chat/slices/translate/action.ts +1 -2
- package/src/store/image/slices/generationTopic/action.ts +6 -2
- package/tsconfig.json +1 -1
- package/.github/workflows/claude-code-review.yml +0 -78
- package/.github/workflows/wiki-sync.yml +0 -19
- /package/{src → packages/prompts/src}/chains/__tests__/__snapshots__/summaryHistory.test.ts.snap +0 -0
- /package/{src → packages/prompts/src}/chains/__tests__/translate.test.ts +0 -0
- /package/packages/prompts/src/{chatMessages → prompts/chatMessages}/index.test.ts +0 -0
- /package/packages/prompts/src/{chatMessages → prompts/chatMessages}/index.ts +0 -0
- /package/packages/prompts/src/{files → prompts/files}/file.ts +0 -0
- /package/packages/prompts/src/{files → prompts/files}/image.ts +0 -0
- /package/packages/prompts/src/{files → prompts/files}/index.ts +0 -0
- /package/packages/prompts/src/{knowledgeBaseQA → prompts/knowledgeBaseQA}/__snapshots__/index.test.ts.snap +0 -0
- /package/packages/prompts/src/{knowledgeBaseQA → prompts/knowledgeBaseQA}/chunk.ts +0 -0
- /package/packages/prompts/src/{knowledgeBaseQA → prompts/knowledgeBaseQA}/index.ts +0 -0
- /package/packages/prompts/src/{knowledgeBaseQA → prompts/knowledgeBaseQA}/knowledge.ts +0 -0
- /package/packages/prompts/src/{knowledgeBaseQA → prompts/knowledgeBaseQA}/userQuery.ts +0 -0
- /package/packages/prompts/src/{plugin → prompts/plugin}/index.test.ts +0 -0
- /package/packages/prompts/src/{plugin → prompts/plugin}/index.ts +0 -0
- /package/packages/prompts/src/{plugin → prompts/plugin}/tools.test.ts +0 -0
- /package/packages/prompts/src/{plugin → prompts/plugin}/tools.ts +0 -0
- /package/packages/prompts/src/{systemRole → prompts/systemRole}/index.ts +0 -0
package/.eslintignore
CHANGED
@@ -29,3 +29,20 @@ logs
|
|
29
29
|
# misc
|
30
30
|
# add other ignore file below
|
31
31
|
.next
|
32
|
+
|
33
|
+
# temporary directories
|
34
|
+
tmp
|
35
|
+
temp
|
36
|
+
.temp
|
37
|
+
.local
|
38
|
+
docs/.local
|
39
|
+
|
40
|
+
# cache directories
|
41
|
+
.cache
|
42
|
+
|
43
|
+
# AI coding tools directories
|
44
|
+
.claude
|
45
|
+
.serena
|
46
|
+
|
47
|
+
# MCP tools
|
48
|
+
/.serena/**
|
@@ -23,7 +23,7 @@ jobs:
|
|
23
23
|
runs-on: ubuntu-latest # 只在 ubuntu 上运行一次检查
|
24
24
|
steps:
|
25
25
|
- name: Checkout base
|
26
|
-
uses: actions/checkout@
|
26
|
+
uses: actions/checkout@v5
|
27
27
|
with:
|
28
28
|
fetch-depth: 0
|
29
29
|
|
@@ -56,7 +56,7 @@ jobs:
|
|
56
56
|
# 输出版本信息,供后续 job 使用
|
57
57
|
version: ${{ steps.set_version.outputs.version }}
|
58
58
|
steps:
|
59
|
-
- uses: actions/checkout@
|
59
|
+
- uses: actions/checkout@v5
|
60
60
|
with:
|
61
61
|
fetch-depth: 0
|
62
62
|
|
@@ -95,7 +95,7 @@ jobs:
|
|
95
95
|
matrix:
|
96
96
|
os: [macos-latest, windows-2025, ubuntu-latest]
|
97
97
|
steps:
|
98
|
-
- uses: actions/checkout@
|
98
|
+
- uses: actions/checkout@v5
|
99
99
|
with:
|
100
100
|
fetch-depth: 0
|
101
101
|
|
@@ -196,7 +196,7 @@ jobs:
|
|
196
196
|
outputs:
|
197
197
|
artifact_path: ${{ steps.set_path.outputs.path }}
|
198
198
|
steps:
|
199
|
-
- uses: actions/checkout@
|
199
|
+
- uses: actions/checkout@v5
|
200
200
|
with:
|
201
201
|
fetch-depth: 0
|
202
202
|
|
@@ -39,7 +39,7 @@ jobs:
|
|
39
39
|
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
|
40
40
|
|
41
41
|
- name: Checkout base
|
42
|
-
uses: actions/checkout@
|
42
|
+
uses: actions/checkout@v5
|
43
43
|
with:
|
44
44
|
fetch-depth: 0
|
45
45
|
|
@@ -80,7 +80,7 @@ jobs:
|
|
80
80
|
|
81
81
|
- name: Build and export
|
82
82
|
id: build
|
83
|
-
uses: docker/build-push-action@
|
83
|
+
uses: docker/build-push-action@v6
|
84
84
|
with:
|
85
85
|
platforms: ${{ matrix.platform }}
|
86
86
|
context: .
|
@@ -111,7 +111,7 @@ jobs:
|
|
111
111
|
runs-on: ubuntu-latest
|
112
112
|
steps:
|
113
113
|
- name: Checkout base
|
114
|
-
uses: actions/checkout@
|
114
|
+
uses: actions/checkout@v5
|
115
115
|
with:
|
116
116
|
fetch-depth: 0
|
117
117
|
|
@@ -39,7 +39,7 @@ jobs:
|
|
39
39
|
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
|
40
40
|
|
41
41
|
- name: Checkout base
|
42
|
-
uses: actions/checkout@
|
42
|
+
uses: actions/checkout@v5
|
43
43
|
with:
|
44
44
|
fetch-depth: 0
|
45
45
|
|
@@ -80,7 +80,7 @@ jobs:
|
|
80
80
|
|
81
81
|
- name: Build and export
|
82
82
|
id: build
|
83
|
-
uses: docker/build-push-action@
|
83
|
+
uses: docker/build-push-action@v6
|
84
84
|
with:
|
85
85
|
platforms: ${{ matrix.platform }}
|
86
86
|
context: .
|
@@ -111,7 +111,7 @@ jobs:
|
|
111
111
|
runs-on: ubuntu-latest
|
112
112
|
steps:
|
113
113
|
- name: Checkout base
|
114
|
-
uses: actions/checkout@
|
114
|
+
uses: actions/checkout@v5
|
115
115
|
with:
|
116
116
|
fetch-depth: 0
|
117
117
|
|
@@ -39,7 +39,7 @@ jobs:
|
|
39
39
|
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
|
40
40
|
|
41
41
|
- name: Checkout base
|
42
|
-
uses: actions/checkout@
|
42
|
+
uses: actions/checkout@v5
|
43
43
|
with:
|
44
44
|
fetch-depth: 0
|
45
45
|
|
@@ -80,7 +80,7 @@ jobs:
|
|
80
80
|
|
81
81
|
- name: Build and export
|
82
82
|
id: build
|
83
|
-
uses: docker/build-push-action@
|
83
|
+
uses: docker/build-push-action@v6
|
84
84
|
with:
|
85
85
|
platforms: ${{ matrix.platform }}
|
86
86
|
context: .
|
@@ -111,7 +111,7 @@ jobs:
|
|
111
111
|
runs-on: ubuntu-latest
|
112
112
|
steps:
|
113
113
|
- name: Checkout base
|
114
|
-
uses: actions/checkout@
|
114
|
+
uses: actions/checkout@v5
|
115
115
|
with:
|
116
116
|
fetch-depth: 0
|
117
117
|
|
@@ -42,12 +42,12 @@ jobs:
|
|
42
42
|
echo "BRANCH=$BRANCH" >> $GITHUB_ENV
|
43
43
|
env:
|
44
44
|
REPO_BRANCH: ${{ matrix.REPO_BRANCH || env.REPO_BRANCH }}
|
45
|
-
- uses: actions/checkout@
|
45
|
+
- uses: actions/checkout@v5
|
46
46
|
with:
|
47
47
|
repository: ${{ env.REPOSITORY }}
|
48
48
|
token: ${{ secrets[matrix.TOKEN_NAME] || secrets[env.TOKEN_NAME] }}
|
49
49
|
ref: ${{ env.BRANCH }}
|
50
|
-
- uses: actions/checkout@
|
50
|
+
- uses: actions/checkout@v5
|
51
51
|
with:
|
52
52
|
repository: 'myactionway/lighthouse-badges'
|
53
53
|
path: temp_lighthouse_badges_nested
|
@@ -19,7 +19,7 @@ jobs:
|
|
19
19
|
runs-on: ubuntu-latest # 只在 ubuntu 上运行一次检查
|
20
20
|
steps:
|
21
21
|
- name: Checkout base
|
22
|
-
uses: actions/checkout@
|
22
|
+
uses: actions/checkout@v5
|
23
23
|
with:
|
24
24
|
fetch-depth: 0
|
25
25
|
|
@@ -47,7 +47,7 @@ jobs:
|
|
47
47
|
version: ${{ steps.set_version.outputs.version }}
|
48
48
|
is_pr_build: ${{ steps.set_version.outputs.is_pr_build }}
|
49
49
|
steps:
|
50
|
-
- uses: actions/checkout@
|
50
|
+
- uses: actions/checkout@v5
|
51
51
|
with:
|
52
52
|
fetch-depth: 0
|
53
53
|
|
@@ -82,7 +82,7 @@ jobs:
|
|
82
82
|
matrix:
|
83
83
|
os: [macos-latest, windows-2025, ubuntu-latest]
|
84
84
|
steps:
|
85
|
-
- uses: actions/checkout@
|
85
|
+
- uses: actions/checkout@v5
|
86
86
|
with:
|
87
87
|
fetch-depth: 0
|
88
88
|
|
@@ -11,7 +11,7 @@ jobs:
|
|
11
11
|
|
12
12
|
services:
|
13
13
|
postgres:
|
14
|
-
image: pgvector/pgvector:
|
14
|
+
image: pgvector/pgvector:pg17
|
15
15
|
env:
|
16
16
|
POSTGRES_PASSWORD: postgres
|
17
17
|
options: >-
|
@@ -20,7 +20,7 @@ jobs:
|
|
20
20
|
- 5432:5432
|
21
21
|
|
22
22
|
steps:
|
23
|
-
- uses: actions/checkout@
|
23
|
+
- uses: actions/checkout@v5
|
24
24
|
|
25
25
|
- name: Setup Node.js
|
26
26
|
uses: actions/setup-node@v4
|
package/.stylelintignore
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# Stylelintignore for LobeHub
|
2
|
+
################################################################
|
3
|
+
|
4
|
+
# dependencies
|
5
|
+
node_modules
|
6
|
+
|
7
|
+
# ci
|
8
|
+
coverage
|
9
|
+
.coverage
|
10
|
+
|
11
|
+
# production
|
12
|
+
dist
|
13
|
+
es
|
14
|
+
lib
|
15
|
+
logs
|
16
|
+
|
17
|
+
# framework specific
|
18
|
+
.next
|
19
|
+
.umi
|
20
|
+
.umi-production
|
21
|
+
.umi-test
|
22
|
+
.dumi/tmp*
|
23
|
+
|
24
|
+
# temporary directories
|
25
|
+
tmp
|
26
|
+
temp
|
27
|
+
.temp
|
28
|
+
.local
|
29
|
+
docs/.local
|
30
|
+
|
31
|
+
# cache directories
|
32
|
+
.cache
|
33
|
+
|
34
|
+
# AI coding tools directories
|
35
|
+
.claude
|
36
|
+
.serena
|
37
|
+
|
38
|
+
# MCP tools
|
39
|
+
/.serena/**
|
package/CHANGELOG.md
CHANGED
@@ -2,6 +2,56 @@
|
|
2
2
|
|
3
3
|
# Changelog
|
4
4
|
|
5
|
+
### [Version 1.114.1](https://github.com/lobehub/lobe-chat/compare/v1.114.0...v1.114.1)
|
6
|
+
|
7
|
+
<sup>Released on **2025-08-21**</sup>
|
8
|
+
|
9
|
+
#### ♻ Code Refactoring
|
10
|
+
|
11
|
+
- **misc**: Move chain into `@lobechat/prompts`.
|
12
|
+
|
13
|
+
<br/>
|
14
|
+
|
15
|
+
<details>
|
16
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
17
|
+
|
18
|
+
#### Code refactoring
|
19
|
+
|
20
|
+
- **misc**: Move chain into `@lobechat/prompts`, closes [#8875](https://github.com/lobehub/lobe-chat/issues/8875) ([c576b97](https://github.com/lobehub/lobe-chat/commit/c576b97))
|
21
|
+
|
22
|
+
</details>
|
23
|
+
|
24
|
+
<div align="right">
|
25
|
+
|
26
|
+
[](#readme-top)
|
27
|
+
|
28
|
+
</div>
|
29
|
+
|
30
|
+
## [Version 1.114.0](https://github.com/lobehub/lobe-chat/compare/v1.113.3...v1.114.0)
|
31
|
+
|
32
|
+
<sup>Released on **2025-08-19**</sup>
|
33
|
+
|
34
|
+
#### ✨ Features
|
35
|
+
|
36
|
+
- **models**: Add Qwen Image Edit model.
|
37
|
+
|
38
|
+
<br/>
|
39
|
+
|
40
|
+
<details>
|
41
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
42
|
+
|
43
|
+
#### What's improved
|
44
|
+
|
45
|
+
- **models**: Add Qwen Image Edit model, closes [#8851](https://github.com/lobehub/lobe-chat/issues/8851) ([4d7a060](https://github.com/lobehub/lobe-chat/commit/4d7a060))
|
46
|
+
|
47
|
+
</details>
|
48
|
+
|
49
|
+
<div align="right">
|
50
|
+
|
51
|
+
[](#readme-top)
|
52
|
+
|
53
|
+
</div>
|
54
|
+
|
5
55
|
### [Version 1.113.3](https://github.com/lobehub/lobe-chat/compare/v1.113.2...v1.113.3)
|
6
56
|
|
7
57
|
<sup>Released on **2025-08-19**</sup>
|
package/changelog/v1.json
CHANGED
@@ -1,4 +1,18 @@
|
|
1
1
|
[
|
2
|
+
{
|
3
|
+
"children": {
|
4
|
+
"improvements": [
|
5
|
+
"Move chain into @lobechat/prompts."
|
6
|
+
]
|
7
|
+
},
|
8
|
+
"date": "2025-08-21",
|
9
|
+
"version": "1.114.1"
|
10
|
+
},
|
11
|
+
{
|
12
|
+
"children": {},
|
13
|
+
"date": "2025-08-19",
|
14
|
+
"version": "1.114.0"
|
15
|
+
},
|
2
16
|
{
|
3
17
|
"children": {
|
4
18
|
"fixes": [
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@lobehub/chat",
|
3
|
-
"version": "1.
|
3
|
+
"version": "1.114.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",
|
@@ -195,6 +195,11 @@ export const createRouterRuntime = ({
|
|
195
195
|
}
|
196
196
|
}
|
197
197
|
|
198
|
+
async createImage(payload: CreateImagePayload) {
|
199
|
+
const runtime = await this.getRuntimeByModel(payload.model);
|
200
|
+
return runtime.createImage!(payload);
|
201
|
+
}
|
202
|
+
|
198
203
|
async textToImage(payload: TextToImagePayload) {
|
199
204
|
const runtime = await this.getRuntimeByModel(payload.model);
|
200
205
|
|
@@ -203,12 +208,12 @@ export const createRouterRuntime = ({
|
|
203
208
|
|
204
209
|
async models() {
|
205
210
|
if (models && typeof models === 'function') {
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
}
|
211
|
+
// 如果是函数式配置,使用最后一个 runtime 的 client 调用函数
|
212
|
+
const lastRuntime = this._runtimes.at(-1)?.runtime;
|
213
|
+
if (lastRuntime && 'client' in lastRuntime) {
|
214
|
+
return await models({ client: (lastRuntime as any).client });
|
211
215
|
}
|
216
|
+
}
|
212
217
|
return this._runtimes.at(-1)?.runtime.models?.();
|
213
218
|
}
|
214
219
|
|
@@ -49,6 +49,22 @@ exports[`LobeOpenAI > models > should get models 1`] = `
|
|
49
49
|
"functionCall": false,
|
50
50
|
"id": "dall-e-2",
|
51
51
|
"maxOutput": undefined,
|
52
|
+
"parameters": {
|
53
|
+
"imageUrl": {
|
54
|
+
"default": null,
|
55
|
+
},
|
56
|
+
"prompt": {
|
57
|
+
"default": "",
|
58
|
+
},
|
59
|
+
"size": {
|
60
|
+
"default": "1024x1024",
|
61
|
+
"enum": [
|
62
|
+
"256x256",
|
63
|
+
"512x512",
|
64
|
+
"1024x1024",
|
65
|
+
],
|
66
|
+
},
|
67
|
+
},
|
52
68
|
"reasoning": false,
|
53
69
|
"releasedAt": "2023-11-01",
|
54
70
|
"type": "image",
|
@@ -231,6 +247,19 @@ exports[`LobeOpenAI > models > should get models 1`] = `
|
|
231
247
|
"functionCall": false,
|
232
248
|
"id": "dall-e-3",
|
233
249
|
"maxOutput": undefined,
|
250
|
+
"parameters": {
|
251
|
+
"prompt": {
|
252
|
+
"default": "",
|
253
|
+
},
|
254
|
+
"size": {
|
255
|
+
"default": "1024x1024",
|
256
|
+
"enum": [
|
257
|
+
"1024x1024",
|
258
|
+
"1792x1024",
|
259
|
+
"1024x1792",
|
260
|
+
],
|
261
|
+
},
|
262
|
+
},
|
234
263
|
"reasoning": false,
|
235
264
|
"releasedAt": "2023-10-31",
|
236
265
|
"type": "image",
|
@@ -85,7 +85,7 @@ export const MODEL_LIST_CONFIGS = {
|
|
85
85
|
export const PROVIDER_DETECTION_CONFIG = {
|
86
86
|
anthropic: ['claude'],
|
87
87
|
deepseek: ['deepseek'],
|
88
|
-
google: ['gemini'],
|
88
|
+
google: ['gemini', 'imagen'],
|
89
89
|
llama: ['llama', 'llava'],
|
90
90
|
moonshot: ['moonshot', 'kimi'],
|
91
91
|
openai: ['o1', 'o3', 'o4', 'gpt-'],
|
@@ -251,7 +251,7 @@ const processModelCard = (
|
|
251
251
|
model: { [key: string]: any; id: string },
|
252
252
|
config: ModelProcessorConfig,
|
253
253
|
knownModel?: any,
|
254
|
-
): ChatModelCard => {
|
254
|
+
): ChatModelCard | undefined => {
|
255
255
|
const {
|
256
256
|
functionCallKeywords = [],
|
257
257
|
visionKeywords = [],
|
@@ -260,6 +260,20 @@ const processModelCard = (
|
|
260
260
|
} = config;
|
261
261
|
|
262
262
|
const isExcludedModel = isKeywordListMatch(model.id.toLowerCase(), excludeKeywords);
|
263
|
+
const modelType =
|
264
|
+
model.type ||
|
265
|
+
knownModel?.type ||
|
266
|
+
(isKeywordListMatch(
|
267
|
+
model.id.toLowerCase(),
|
268
|
+
IMAGE_MODEL_KEYWORDS.map((k) => k.toLowerCase()),
|
269
|
+
)
|
270
|
+
? 'image'
|
271
|
+
: 'chat');
|
272
|
+
|
273
|
+
// image model can't find parameters
|
274
|
+
if (modelType === 'image' && !model.parameters && !knownModel?.parameters) {
|
275
|
+
return undefined;
|
276
|
+
}
|
263
277
|
|
264
278
|
return {
|
265
279
|
contextWindowTokens: model.contextWindowTokens ?? knownModel?.contextWindowTokens ?? undefined,
|
@@ -281,15 +295,11 @@ const processModelCard = (
|
|
281
295
|
knownModel?.abilities?.reasoning ??
|
282
296
|
(isKeywordListMatch(model.id.toLowerCase(), reasoningKeywords) || false),
|
283
297
|
releasedAt: processReleasedAt(model, knownModel),
|
284
|
-
type:
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
IMAGE_MODEL_KEYWORDS.map((k) => k.toLowerCase()),
|
290
|
-
)
|
291
|
-
? 'image'
|
292
|
-
: 'chat'),
|
298
|
+
type: modelType,
|
299
|
+
// current, only image model use the parameters field
|
300
|
+
...(modelType === 'image' && {
|
301
|
+
parameters: model.parameters ?? knownModel?.parameters,
|
302
|
+
}),
|
293
303
|
vision:
|
294
304
|
model.vision ??
|
295
305
|
knownModel?.abilities?.vision ??
|
@@ -329,7 +339,7 @@ export const processModelList = async (
|
|
329
339
|
|
330
340
|
return processModelCard(model, config, knownModel);
|
331
341
|
}),
|
332
|
-
).then((results) => results.filter(
|
342
|
+
).then((results) => results.filter((result) => !!result));
|
333
343
|
};
|
334
344
|
|
335
345
|
/**
|
@@ -348,8 +358,7 @@ export const processMultiProviderModelList = async (
|
|
348
358
|
let providerLocalConfig: any[] | null = null;
|
349
359
|
if (providerid) {
|
350
360
|
try {
|
351
|
-
const
|
352
|
-
const moduleImport = await import(modulePath);
|
361
|
+
const moduleImport = await import(`@/config/aiModels/${providerid}`);
|
353
362
|
providerLocalConfig = moduleImport.default;
|
354
363
|
} catch {
|
355
364
|
// 如果配置文件不存在或导入失败,保持为 null
|
@@ -381,11 +390,15 @@ export const processMultiProviderModelList = async (
|
|
381
390
|
const processedModel = processModelCard(model, config, knownModel);
|
382
391
|
|
383
392
|
// 如果找到了本地配置中的模型,使用其 enabled 状态
|
384
|
-
if (
|
393
|
+
if (
|
394
|
+
processedModel &&
|
395
|
+
providerLocalModelConfig &&
|
396
|
+
typeof providerLocalModelConfig.enabled === 'boolean'
|
397
|
+
) {
|
385
398
|
processedModel.enabled = providerLocalModelConfig.enabled;
|
386
399
|
}
|
387
400
|
|
388
401
|
return processedModel;
|
389
402
|
}),
|
390
|
-
).then((results) => results.filter(
|
403
|
+
).then((results) => results.filter((result) => !!result));
|
391
404
|
};
|
@@ -1,25 +1,15 @@
|
|
1
|
-
import {
|
2
|
-
|
3
|
-
import { globalHelpers } from '@/store/global/helpers';
|
1
|
+
import { describe, expect, it } from 'vitest';
|
4
2
|
|
5
3
|
import { chainSummaryAgentName } from '../summaryAgentName';
|
6
4
|
|
7
|
-
// Mock the getCurrentLanguage function
|
8
|
-
vi.mock('@/store/global/helpers', () => ({
|
9
|
-
globalHelpers: {
|
10
|
-
getCurrentLanguage: vi.fn(),
|
11
|
-
},
|
12
|
-
}));
|
13
|
-
|
14
5
|
describe('chainSummaryAgentName', () => {
|
15
6
|
it('should create a payload with system and user messages including the provided content and current language', () => {
|
16
7
|
// Arrange
|
17
8
|
const content = '这是一段测试文本';
|
18
9
|
const currentLanguage = 'en-US';
|
19
|
-
(globalHelpers.getCurrentLanguage as Mock).mockReturnValue(currentLanguage);
|
20
10
|
|
21
11
|
// Act
|
22
|
-
const result = chainSummaryAgentName(content);
|
12
|
+
const result = chainSummaryAgentName(content, currentLanguage);
|
23
13
|
|
24
14
|
// Assert
|
25
15
|
expect(result).toEqual({
|
@@ -50,8 +40,5 @@ describe('chainSummaryAgentName', () => {
|
|
50
40
|
{ content: `输入: {${content}} [${currentLanguage}]`, role: 'user' },
|
51
41
|
],
|
52
42
|
});
|
53
|
-
|
54
|
-
// Verify that the getCurrentLanguage function was called
|
55
|
-
expect(globalHelpers.getCurrentLanguage).toHaveBeenCalled();
|
56
43
|
});
|
57
44
|
});
|
@@ -4,13 +4,6 @@ import { globalHelpers } from '@/store/global/helpers';
|
|
4
4
|
|
5
5
|
import { chainSummaryDescription } from '../summaryDescription';
|
6
6
|
|
7
|
-
// Mock the globalHelpers.getCurrentLanguage function
|
8
|
-
vi.mock('@/store/global/helpers', () => ({
|
9
|
-
globalHelpers: {
|
10
|
-
getCurrentLanguage: vi.fn(() => 'en-US'),
|
11
|
-
},
|
12
|
-
}));
|
13
|
-
|
14
7
|
describe('chainSummaryDescription', () => {
|
15
8
|
it('should return a payload with the correct structure and content based on the input', () => {
|
16
9
|
const inputContent = '你是一个专业的JavaScript开发者';
|
@@ -64,17 +57,14 @@ nav: API
|
|
64
57
|
temperature: 0,
|
65
58
|
};
|
66
59
|
|
67
|
-
const result = chainSummaryDescription(inputContent);
|
60
|
+
const result = chainSummaryDescription(inputContent, 'en-US');
|
68
61
|
|
69
62
|
expect(result).toEqual(expectedOutput);
|
70
63
|
});
|
71
64
|
|
72
65
|
it('should handle different languages', () => {
|
73
|
-
// Override the getCurrentLanguage mock to return a different language
|
74
|
-
(globalHelpers.getCurrentLanguage as Mock).mockReturnValueOnce('zh-CN');
|
75
|
-
|
76
66
|
const inputContent = '你是一个专业的JavaScript开发者';
|
77
|
-
const result = chainSummaryDescription(inputContent);
|
67
|
+
const result = chainSummaryDescription(inputContent, 'zh-CN');
|
78
68
|
|
79
69
|
// Verify that the language in the output matches the mocked language
|
80
70
|
expect(result.messages![0].content).toContain('翻译为目标语言:zh-CN');
|
@@ -1,10 +1,6 @@
|
|
1
|
+
import { ChatMessage } from '@lobechat/types';
|
1
2
|
import { Mock, describe, expect, it, vi } from 'vitest';
|
2
3
|
|
3
|
-
import { chatHelpers } from '@/store/chat/helpers';
|
4
|
-
import { globalHelpers } from '@/store/global/helpers';
|
5
|
-
import { ChatMessage } from '@/types/message';
|
6
|
-
import { OpenAIChatMessage } from '@/types/openai/chat';
|
7
|
-
|
8
4
|
import { chainSummaryHistory } from '../summaryHistory';
|
9
5
|
|
10
6
|
describe('chainSummaryHistory', () => {
|