@lobehub/chat 1.114.0 → 1.114.2

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 (92) hide show
  1. package/.eslintignore +17 -0
  2. package/.github/workflows/auto-i18n.yml +1 -1
  3. package/.github/workflows/claude.yml +1 -1
  4. package/.github/workflows/desktop-pr-build.yml +4 -4
  5. package/.github/workflows/docker-database.yml +3 -3
  6. package/.github/workflows/docker-pglite.yml +3 -3
  7. package/.github/workflows/docker.yml +3 -3
  8. package/.github/workflows/lighthouse.yml +2 -2
  9. package/.github/workflows/release-desktop-beta.yml +3 -3
  10. package/.github/workflows/release.yml +2 -2
  11. package/.github/workflows/sync-database-schema.yml +1 -1
  12. package/.github/workflows/sync.yml +1 -1
  13. package/.github/workflows/test.yml +76 -14
  14. package/.stylelintignore +39 -0
  15. package/CHANGELOG.md +50 -0
  16. package/changelog/v1.json +18 -0
  17. package/package.json +1 -1
  18. package/packages/const/src/index.ts +2 -0
  19. package/packages/electron-server-ipc/package.json +2 -1
  20. package/packages/electron-server-ipc/vitest.config.ts +10 -0
  21. package/packages/file-loaders/package.json +2 -1
  22. package/packages/model-runtime/package.json +4 -0
  23. package/packages/model-runtime/src/baichuan/index.test.ts +1 -1
  24. package/packages/model-runtime/src/mistral/index.test.ts +1 -1
  25. package/packages/model-runtime/src/utils/anthropicHelpers.test.ts +1 -1
  26. package/packages/model-runtime/src/utils/modelParse.ts +1 -2
  27. package/packages/model-runtime/vitest.config.ts +16 -0
  28. package/packages/prompts/package.json +5 -0
  29. package/{src → packages/prompts/src}/chains/__tests__/langDetect.test.ts +1 -2
  30. package/{src → packages/prompts/src}/chains/__tests__/pickEmoji.test.ts +1 -2
  31. package/{src → packages/prompts/src}/chains/__tests__/summaryAgentName.test.ts +2 -15
  32. package/{src → packages/prompts/src}/chains/__tests__/summaryDescription.test.ts +4 -16
  33. package/{src → packages/prompts/src}/chains/__tests__/summaryHistory.test.ts +1 -5
  34. package/{src → packages/prompts/src}/chains/__tests__/summaryTags.test.ts +1 -14
  35. package/{src → packages/prompts/src}/chains/__tests__/summaryTitle.test.ts +3 -22
  36. package/{src → packages/prompts/src}/chains/abstractChunk.ts +2 -2
  37. package/{src → packages/prompts/src}/chains/answerWithContext.ts +1 -1
  38. package/packages/prompts/src/chains/index.ts +12 -0
  39. package/{src → packages/prompts/src}/chains/langDetect.ts +1 -1
  40. package/{src → packages/prompts/src}/chains/pickEmoji.ts +1 -1
  41. package/{src → packages/prompts/src}/chains/rewriteQuery.ts +2 -2
  42. package/{src → packages/prompts/src}/chains/summaryAgentName.ts +6 -5
  43. package/{src → packages/prompts/src}/chains/summaryDescription.ts +7 -5
  44. package/{src → packages/prompts/src}/chains/summaryGenerationTitle.ts +3 -5
  45. package/{src → packages/prompts/src}/chains/summaryHistory.ts +2 -3
  46. package/{src → packages/prompts/src}/chains/summaryTags.ts +3 -4
  47. package/{src → packages/prompts/src}/chains/summaryTitle.ts +5 -5
  48. package/{src → packages/prompts/src}/chains/translate.ts +1 -1
  49. package/packages/prompts/src/index.ts +2 -5
  50. package/packages/prompts/src/{files → prompts/files}/index.test.ts +1 -2
  51. package/packages/prompts/src/prompts/index.ts +5 -0
  52. package/packages/prompts/src/{knowledgeBaseQA → prompts/knowledgeBaseQA}/index.test.ts +1 -3
  53. package/packages/prompts/src/{plugin → prompts/plugin}/index.test.ts +2 -0
  54. package/packages/prompts/vitest.config.ts +7 -0
  55. package/packages/types/src/index.ts +4 -0
  56. package/packages/web-crawler/package.json +4 -0
  57. package/packages/web-crawler/src/crawImpl/__tests__/jina.test.ts +1 -1
  58. package/packages/web-crawler/src/crawImpl/__tests__/search1api.test.ts +1 -1
  59. package/packages/web-crawler/src/utils/__tests__/withTimeout.test.ts +1 -1
  60. package/packages/web-crawler/src/utils/appUrlRules.test.ts +2 -0
  61. package/packages/web-crawler/src/utils/htmlToMarkdown.test.ts +1 -1
  62. package/packages/web-crawler/vitest.config.ts +7 -0
  63. package/src/app/[variants]/(main)/settings/provider/(detail)/[id]/ClientMode.tsx +4 -0
  64. package/src/features/AgentSetting/store/action.ts +19 -7
  65. package/src/server/routers/async/ragEval.ts +1 -1
  66. package/src/store/chat/slices/aiChat/actions/memory.ts +1 -1
  67. package/src/store/chat/slices/aiChat/actions/rag.ts +1 -1
  68. package/src/store/chat/slices/thread/action.ts +3 -2
  69. package/src/store/chat/slices/topic/action.ts +3 -2
  70. package/src/store/chat/slices/translate/action.test.ts +2 -2
  71. package/src/store/chat/slices/translate/action.ts +1 -2
  72. package/src/store/image/slices/generationTopic/action.ts +6 -2
  73. package/tsconfig.json +1 -1
  74. package/vitest.config.ts +2 -0
  75. package/.github/workflows/claude-code-review.yml +0 -78
  76. package/.github/workflows/wiki-sync.yml +0 -19
  77. /package/{src → packages/prompts/src}/chains/__tests__/__snapshots__/summaryHistory.test.ts.snap +0 -0
  78. /package/{src → packages/prompts/src}/chains/__tests__/translate.test.ts +0 -0
  79. /package/packages/prompts/src/{chatMessages → prompts/chatMessages}/index.test.ts +0 -0
  80. /package/packages/prompts/src/{chatMessages → prompts/chatMessages}/index.ts +0 -0
  81. /package/packages/prompts/src/{files → prompts/files}/file.ts +0 -0
  82. /package/packages/prompts/src/{files → prompts/files}/image.ts +0 -0
  83. /package/packages/prompts/src/{files → prompts/files}/index.ts +0 -0
  84. /package/packages/prompts/src/{knowledgeBaseQA → prompts/knowledgeBaseQA}/__snapshots__/index.test.ts.snap +0 -0
  85. /package/packages/prompts/src/{knowledgeBaseQA → prompts/knowledgeBaseQA}/chunk.ts +0 -0
  86. /package/packages/prompts/src/{knowledgeBaseQA → prompts/knowledgeBaseQA}/index.ts +0 -0
  87. /package/packages/prompts/src/{knowledgeBaseQA → prompts/knowledgeBaseQA}/knowledge.ts +0 -0
  88. /package/packages/prompts/src/{knowledgeBaseQA → prompts/knowledgeBaseQA}/userQuery.ts +0 -0
  89. /package/packages/prompts/src/{plugin → prompts/plugin}/index.ts +0 -0
  90. /package/packages/prompts/src/{plugin → prompts/plugin}/tools.test.ts +0 -0
  91. /package/packages/prompts/src/{plugin → prompts/plugin}/tools.ts +0 -0
  92. /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/**
@@ -21,7 +21,7 @@ jobs:
21
21
  git config --global user.name "lobehubbot"
22
22
  git config --global user.email "i@lobehub.com"
23
23
 
24
- - uses: actions/checkout@v4
24
+ - uses: actions/checkout@v5
25
25
  with:
26
26
  ref: ${{ github.event.pull_request.head.ref }}
27
27
 
@@ -26,7 +26,7 @@ jobs:
26
26
  actions: read # Required for Claude to read CI results on PRs
27
27
  steps:
28
28
  - name: Checkout repository
29
- uses: actions/checkout@v4
29
+ uses: actions/checkout@v5
30
30
  with:
31
31
  fetch-depth: 1
32
32
 
@@ -23,7 +23,7 @@ jobs:
23
23
  runs-on: ubuntu-latest # 只在 ubuntu 上运行一次检查
24
24
  steps:
25
25
  - name: Checkout base
26
- uses: actions/checkout@v4
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@v4
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@v4
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@v4
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@v4
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@v5
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@v4
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@v4
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@v5
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@v4
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@v4
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@v5
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@v4
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@v4
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@v4
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@v4
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@v4
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@v4
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:pg16
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@v4
23
+ - uses: actions/checkout@v5
24
24
 
25
25
  - name: Setup Node.js
26
26
  uses: actions/setup-node@v4
@@ -11,7 +11,7 @@ jobs:
11
11
  build:
12
12
  runs-on: ubuntu-latest
13
13
  steps:
14
- - uses: actions/checkout@v4
14
+ - uses: actions/checkout@v5
15
15
 
16
16
  - name: Install dbdocs
17
17
  run: sudo npm install -g dbdocs
@@ -17,7 +17,7 @@ jobs:
17
17
  if: ${{ github.event.repository.fork }}
18
18
 
19
19
  steps:
20
- - uses: actions/checkout@v4
20
+ - uses: actions/checkout@v5
21
21
 
22
22
  - name: Clean issue notice
23
23
  uses: actions-cool/issues-helper@v3
@@ -2,8 +2,82 @@ name: Test CI
2
2
 
3
3
  on: [push, pull_request]
4
4
 
5
+ permissions:
6
+ contents: read
7
+
5
8
  jobs:
6
- test:
9
+ # Package tests - using each package's own test script
10
+ test-packages:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ package: [file-loaders, prompts, model-runtime, web-crawler, electron-server-ipc]
15
+
16
+ name: Test package ${{ matrix.package }}
17
+
18
+ steps:
19
+ - uses: actions/checkout@v5
20
+
21
+ - name: Setup Node.js
22
+ uses: actions/setup-node@v4
23
+ with:
24
+ node-version: 22
25
+
26
+ - uses: pnpm/action-setup@v4
27
+
28
+ - name: Install bun
29
+ uses: oven-sh/setup-bun@v1
30
+ with:
31
+ bun-version: ${{ secrets.BUN_VERSION }}
32
+
33
+ - name: Install deps
34
+ run: bun i
35
+
36
+ - name: Test ${{ matrix.package }} package with coverage
37
+ run: pnpm --filter @lobechat/${{ matrix.package }} test:coverage
38
+
39
+ - name: Upload ${{ matrix.package }} coverage to Codecov
40
+ uses: codecov/codecov-action@v4
41
+ with:
42
+ token: ${{ secrets.CODECOV_TOKEN }}
43
+ files: ./packages/${{ matrix.package }}/coverage/lcov.info
44
+ flags: packages/${{ matrix.package }}
45
+
46
+ # App tests
47
+ test-website:
48
+ name: Test Website
49
+
50
+ runs-on: ubuntu-latest
51
+
52
+ steps:
53
+ - uses: actions/checkout@v5
54
+
55
+ - name: Setup Node.js
56
+ uses: actions/setup-node@v4
57
+ with:
58
+ node-version: 22
59
+
60
+ - name: Install bun
61
+ uses: oven-sh/setup-bun@v1
62
+ with:
63
+ bun-version: ${{ secrets.BUN_VERSION }}
64
+
65
+ - name: Install deps
66
+ run: bun i
67
+
68
+ - name: Test App Coverage
69
+ run: bun run test-app:coverage
70
+
71
+ - name: Upload App Coverage to Codecov
72
+ uses: codecov/codecov-action@v4
73
+ with:
74
+ token: ${{ secrets.CODECOV_TOKEN }}
75
+ files: ./coverage/app/lcov.info
76
+ flags: app
77
+
78
+ test-server:
79
+ name: Test Database
80
+
7
81
  runs-on: ubuntu-latest
8
82
 
9
83
  services:
@@ -13,13 +87,11 @@ jobs:
13
87
  POSTGRES_PASSWORD: postgres
14
88
  options: >-
15
89
  --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
16
-
17
-
18
90
  ports:
19
91
  - 5432:5432
20
92
 
21
93
  steps:
22
- - uses: actions/checkout@v4
94
+ - uses: actions/checkout@v5
23
95
 
24
96
  - name: Setup Node.js
25
97
  uses: actions/setup-node@v4
@@ -53,13 +125,3 @@ jobs:
53
125
  token: ${{ secrets.CODECOV_TOKEN }}
54
126
  files: ./coverage/server/lcov.info
55
127
  flags: server
56
-
57
- - name: Test App Coverage
58
- run: bun run test-app:coverage
59
-
60
- - name: Upload App Coverage to Codecov
61
- uses: codecov/codecov-action@v4
62
- with:
63
- token: ${{ secrets.CODECOV_TOKEN }}
64
- files: ./coverage/app/lcov.info
65
- flags: app
@@ -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.2](https://github.com/lobehub/lobe-chat/compare/v1.114.1...v1.114.2)
6
+
7
+ <sup>Released on **2025-08-21**</sup>
8
+
9
+ #### 🐛 Bug Fixes
10
+
11
+ - **misc**: Can't load custom provider config.
12
+
13
+ <br/>
14
+
15
+ <details>
16
+ <summary><kbd>Improvements and Fixes</kbd></summary>
17
+
18
+ #### What's fixed
19
+
20
+ - **misc**: Can't load custom provider config, closes [#8880](https://github.com/lobehub/lobe-chat/issues/8880) ([9ec3315](https://github.com/lobehub/lobe-chat/commit/9ec3315))
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.114.1](https://github.com/lobehub/lobe-chat/compare/v1.114.0...v1.114.1)
31
+
32
+ <sup>Released on **2025-08-21**</sup>
33
+
34
+ #### ♻ Code Refactoring
35
+
36
+ - **misc**: Move chain into `@lobechat/prompts`.
37
+
38
+ <br/>
39
+
40
+ <details>
41
+ <summary><kbd>Improvements and Fixes</kbd></summary>
42
+
43
+ #### Code refactoring
44
+
45
+ - **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))
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.114.0](https://github.com/lobehub/lobe-chat/compare/v1.113.3...v1.114.0)
6
56
 
7
57
  <sup>Released on **2025-08-19**</sup>
package/changelog/v1.json CHANGED
@@ -1,4 +1,22 @@
1
1
  [
2
+ {
3
+ "children": {
4
+ "fixes": [
5
+ "Can't load custom provider config."
6
+ ]
7
+ },
8
+ "date": "2025-08-21",
9
+ "version": "1.114.2"
10
+ },
11
+ {
12
+ "children": {
13
+ "improvements": [
14
+ "Move chain into @lobechat/prompts."
15
+ ]
16
+ },
17
+ "date": "2025-08-21",
18
+ "version": "1.114.1"
19
+ },
2
20
  {
3
21
  "children": {},
4
22
  "date": "2025-08-19",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/chat",
3
- "version": "1.114.0",
3
+ "version": "1.114.2",
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",
@@ -0,0 +1,2 @@
1
+ export * from './settings';
2
+ export * from './version';
@@ -5,7 +5,8 @@
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
7
7
  "scripts": {
8
- "test": "vitest"
8
+ "test": "vitest",
9
+ "test:coverage": "vitest --coverage"
9
10
  },
10
11
  "dependencies": {
11
12
  "debug": "^4.3.4"
@@ -0,0 +1,10 @@
1
+ import { defineConfig } from 'vitest/config';
2
+
3
+ export default defineConfig({
4
+ test: {
5
+ coverage: {
6
+ all: false,
7
+ },
8
+ environment: 'node',
9
+ },
10
+ });
@@ -21,7 +21,8 @@
21
21
  "sideEffects": false,
22
22
  "main": "./src/index.ts",
23
23
  "scripts": {
24
- "test": "vitest"
24
+ "test": "vitest",
25
+ "test:coverage": "vitest --coverage"
25
26
  },
26
27
  "dependencies": {
27
28
  "@langchain/community": "^0.3.41",
@@ -3,6 +3,10 @@
3
3
  "version": "1.0.0",
4
4
  "private": true,
5
5
  "main": "./src/index.ts",
6
+ "scripts": {
7
+ "test": "vitest",
8
+ "test:coverage": "vitest --coverage"
9
+ },
6
10
  "dependencies": {
7
11
  "@aws-sdk/client-bedrock-runtime": "^3.862.0",
8
12
  "@lobechat/types": "workspace:*",
@@ -1,5 +1,5 @@
1
1
  // @vitest-environment node
2
- import { Mock } from 'vitest';
2
+ import { Mock, afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
3
3
 
4
4
  import { LobeOpenAICompatibleRuntime, ModelProvider } from '@/libs/model-runtime';
5
5
 
@@ -1,5 +1,5 @@
1
1
  // @vitest-environment node
2
- import { Mock, afterEach, beforeEach, expect, it, vi } from 'vitest';
2
+ import { Mock, afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
3
3
 
4
4
  import { LobeOpenAICompatibleRuntime } from '@/libs/model-runtime';
5
5
  import { testProvider } from '@/libs/model-runtime/providerTestUtils';
@@ -1,5 +1,5 @@
1
1
  import { OpenAI } from 'openai';
2
- import { describe, expect, it } from 'vitest';
2
+ import { describe, expect, it, vi } from 'vitest';
3
3
 
4
4
  import { imageUrlToBase64 } from '@/utils/imageToBase64';
5
5
 
@@ -358,8 +358,7 @@ export const processMultiProviderModelList = async (
358
358
  let providerLocalConfig: any[] | null = null;
359
359
  if (providerid) {
360
360
  try {
361
- const modulePath = `@/config/aiModels/${providerid}`;
362
- const moduleImport = await import(modulePath);
361
+ const moduleImport = await import(`@/config/aiModels/${providerid}`);
363
362
  providerLocalConfig = moduleImport.default;
364
363
  } catch {
365
364
  // 如果配置文件不存在或导入失败,保持为 null
@@ -0,0 +1,16 @@
1
+ import { resolve } from 'node:path';
2
+ import { defineConfig } from 'vitest/config';
3
+
4
+ export default defineConfig({
5
+ test: {
6
+ alias: {
7
+ /* eslint-disable sort-keys-fix/sort-keys-fix */
8
+ '@/libs/model-runtime': resolve(__dirname, './src'),
9
+ '@/types': resolve(__dirname, '../types/src'),
10
+ '@/const': resolve(__dirname, '../const/src'),
11
+ '@': resolve(__dirname, '../../src'),
12
+ /* eslint-enable */
13
+ },
14
+ environment: 'happy-dom',
15
+ },
16
+ });
@@ -3,7 +3,12 @@
3
3
  "version": "1.0.0",
4
4
  "private": true,
5
5
  "main": "./src/index.ts",
6
+ "scripts": {
7
+ "test": "vitest",
8
+ "test:coverage": "vitest --coverage"
9
+ },
6
10
  "dependencies": {
11
+ "@lobechat/const": "workspace:*",
7
12
  "@lobechat/types": "workspace:*"
8
13
  }
9
14
  }
@@ -1,7 +1,6 @@
1
+ import { ChatStreamPayload } from '@lobechat/types';
1
2
  import { describe, expect, it } from 'vitest';
2
3
 
3
- import { ChatStreamPayload } from '@/types/openai/chat';
4
-
5
4
  import { chainLangDetect } from '../langDetect';
6
5
 
7
6
  // 描述测试块
@@ -1,7 +1,6 @@
1
+ import { ChatStreamPayload } from '@lobechat/types';
1
2
  import { describe, expect, it } from 'vitest';
2
3
 
3
- import { ChatStreamPayload } from '@/types/openai/chat';
4
-
5
4
  import { chainPickEmoji } from '../pickEmoji';
6
5
 
7
6
  // 描述测试块
@@ -1,25 +1,15 @@
1
- import { Mock, describe, expect, it } from 'vitest';
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
  });