@lobehub/chat 1.116.3 → 1.116.4
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/.github/PULL_REQUEST_TEMPLATE.md +1 -0
- package/.github/workflows/release.yml +2 -0
- package/.i18nrc.js +1 -1
- package/CHANGELOG.md +25 -0
- package/changelog/v1.json +9 -0
- package/locales/ar/components.json +12 -0
- package/locales/bg-BG/components.json +12 -0
- package/locales/de-DE/components.json +12 -0
- package/locales/en-US/components.json +12 -0
- package/locales/es-ES/components.json +12 -0
- package/locales/fa-IR/components.json +12 -0
- package/locales/fr-FR/components.json +12 -0
- package/locales/it-IT/components.json +12 -0
- package/locales/ja-JP/components.json +12 -0
- package/locales/ko-KR/components.json +12 -0
- package/locales/nl-NL/components.json +12 -0
- package/locales/pl-PL/components.json +12 -0
- package/locales/pt-BR/components.json +12 -0
- package/locales/ru-RU/components.json +12 -0
- package/locales/tr-TR/components.json +12 -0
- package/locales/vi-VN/components.json +12 -0
- package/locales/zh-CN/components.json +12 -0
- package/locales/zh-TW/components.json +12 -0
- package/package.json +5 -5
- package/packages/const/src/index.ts +2 -1
- package/packages/const/src/meta.ts +3 -2
- package/packages/const/src/settings/agent.ts +9 -4
- package/packages/const/src/settings/systemAgent.ts +0 -3
- package/packages/file-loaders/vitest.config.mts +3 -7
- package/packages/model-runtime/vitest.config.mts +3 -0
- package/packages/prompts/package.json +0 -1
- package/packages/prompts/src/chains/__tests__/abstractChunk.test.ts +52 -0
- package/packages/prompts/src/chains/__tests__/answerWithContext.test.ts +100 -0
- package/packages/prompts/src/chains/__tests__/rewriteQuery.test.ts +88 -0
- package/packages/prompts/src/chains/__tests__/summaryGenerationTitle.test.ts +107 -0
- package/packages/prompts/src/chains/abstractChunk.ts +0 -2
- package/packages/prompts/src/chains/rewriteQuery.ts +3 -1
- package/packages/prompts/src/index.test.ts +41 -0
- package/packages/prompts/src/prompts/systemRole/index.test.ts +136 -0
- package/packages/prompts/vitest.config.mts +3 -0
- package/packages/types/src/index.ts +2 -0
- package/packages/utils/package.json +5 -1
- package/packages/utils/src/client/index.ts +2 -0
- package/packages/utils/src/server/index.ts +5 -0
- package/packages/utils/vitest.config.mts +3 -0
- package/src/app/(backend)/middleware/auth/index.test.ts +2 -2
- package/src/app/(backend)/middleware/auth/index.ts +1 -1
- package/src/app/(backend)/oidc/consent/route.ts +1 -2
- package/src/app/(backend)/webapi/chat/[provider]/route.test.ts +2 -2
- package/src/app/(backend)/webapi/plugin/gateway/route.ts +1 -1
- package/src/app/[variants]/(main)/files/[id]/page.tsx +1 -1
- package/src/app/[variants]/(main)/settings/sync/page.tsx +1 -1
- package/src/app/[variants]/(main)/settings/system-agent/index.tsx +2 -1
- package/src/components/HtmlPreview/HtmlPreviewAction.tsx +32 -0
- package/src/components/HtmlPreview/PreviewDrawer.tsx +133 -0
- package/src/components/HtmlPreview/index.ts +2 -0
- package/src/features/Conversation/components/ChatItem/ShareMessageModal/ShareText/index.tsx +1 -1
- package/src/features/Conversation/components/ChatItem/index.tsx +23 -0
- package/src/features/ShareModal/ShareJSON/index.tsx +2 -2
- package/src/features/ShareModal/ShareText/index.tsx +1 -1
- package/src/libs/oidc-provider/adapter.ts +1 -1
- package/src/libs/trpc/edge/middleware/jwtPayload.test.ts +1 -1
- package/src/libs/trpc/edge/middleware/jwtPayload.ts +1 -2
- package/src/libs/trpc/lambda/middleware/keyVaults.ts +1 -2
- package/src/locales/default/components.ts +12 -0
- package/src/middleware.ts +3 -3
- package/src/server/routers/tools/search.test.ts +1 -1
- package/src/services/config.ts +2 -4
- package/src/utils/client/switchLang.ts +1 -1
- package/{packages/utils/src → src/utils}/server/pageProps.ts +2 -1
- package/tsconfig.json +1 -1
- package/vitest.config.mts +1 -0
- /package/{packages/const/src → src/const}/locale.ts +0 -0
- /package/{packages/utils/src → src/utils}/locale.test.ts +0 -0
- /package/{packages/utils/src → src/utils}/locale.ts +0 -0
- /package/{packages/utils/src → src/utils}/server/routeVariants.ts +0 -0
package/.i18nrc.js
CHANGED
package/CHANGELOG.md
CHANGED
@@ -2,6 +2,31 @@
|
|
2
2
|
|
3
3
|
# Changelog
|
4
4
|
|
5
|
+
### [Version 1.116.4](https://github.com/lobehub/lobe-chat/compare/v1.116.3...v1.116.4)
|
6
|
+
|
7
|
+
<sup>Released on **2025-08-28**</sup>
|
8
|
+
|
9
|
+
#### 💄 Styles
|
10
|
+
|
11
|
+
- **misc**: Support html preview.
|
12
|
+
|
13
|
+
<br/>
|
14
|
+
|
15
|
+
<details>
|
16
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
17
|
+
|
18
|
+
#### Styles
|
19
|
+
|
20
|
+
- **misc**: Support html preview, closes [#8969](https://github.com/lobehub/lobe-chat/issues/8969) ([82abf6d](https://github.com/lobehub/lobe-chat/commit/82abf6d))
|
21
|
+
|
22
|
+
</details>
|
23
|
+
|
24
|
+
<div align="right">
|
25
|
+
|
26
|
+
[](#readme-top)
|
27
|
+
|
28
|
+
</div>
|
29
|
+
|
5
30
|
### [Version 1.116.3](https://github.com/lobehub/lobe-chat/compare/v1.116.2...v1.116.3)
|
6
31
|
|
7
32
|
<sup>Released on **2025-08-28**</sup>
|
package/changelog/v1.json
CHANGED
@@ -73,6 +73,18 @@
|
|
73
73
|
"GoBack": {
|
74
74
|
"back": "عودة"
|
75
75
|
},
|
76
|
+
"HtmlPreview": {
|
77
|
+
"actions": {
|
78
|
+
"download": "تنزيل",
|
79
|
+
"preview": "معاينة"
|
80
|
+
},
|
81
|
+
"iframeTitle": "معاينة HTML",
|
82
|
+
"mode": {
|
83
|
+
"code": "رمز",
|
84
|
+
"preview": "معاينة"
|
85
|
+
},
|
86
|
+
"title": "معاينة HTML"
|
87
|
+
},
|
76
88
|
"ImageUpload": {
|
77
89
|
"actions": {
|
78
90
|
"changeImage": "انقر لتغيير الصورة",
|
@@ -73,6 +73,18 @@
|
|
73
73
|
"GoBack": {
|
74
74
|
"back": "Назад"
|
75
75
|
},
|
76
|
+
"HtmlPreview": {
|
77
|
+
"actions": {
|
78
|
+
"download": "Изтегляне",
|
79
|
+
"preview": "Преглед"
|
80
|
+
},
|
81
|
+
"iframeTitle": "HTML Преглед",
|
82
|
+
"mode": {
|
83
|
+
"code": "Код",
|
84
|
+
"preview": "Преглед"
|
85
|
+
},
|
86
|
+
"title": "HTML Преглед"
|
87
|
+
},
|
76
88
|
"ImageUpload": {
|
77
89
|
"actions": {
|
78
90
|
"changeImage": "Кликнете, за да смените изображението",
|
@@ -73,6 +73,18 @@
|
|
73
73
|
"GoBack": {
|
74
74
|
"back": "Zurück"
|
75
75
|
},
|
76
|
+
"HtmlPreview": {
|
77
|
+
"actions": {
|
78
|
+
"download": "Herunterladen",
|
79
|
+
"preview": "Vorschau"
|
80
|
+
},
|
81
|
+
"iframeTitle": "HTML-Vorschau",
|
82
|
+
"mode": {
|
83
|
+
"code": "Code",
|
84
|
+
"preview": "Vorschau"
|
85
|
+
},
|
86
|
+
"title": "HTML-Vorschau"
|
87
|
+
},
|
76
88
|
"ImageUpload": {
|
77
89
|
"actions": {
|
78
90
|
"changeImage": "Klicken, um das Bild zu ändern",
|
@@ -73,6 +73,18 @@
|
|
73
73
|
"GoBack": {
|
74
74
|
"back": "Back"
|
75
75
|
},
|
76
|
+
"HtmlPreview": {
|
77
|
+
"actions": {
|
78
|
+
"download": "Download",
|
79
|
+
"preview": "Preview"
|
80
|
+
},
|
81
|
+
"iframeTitle": "HTML Preview",
|
82
|
+
"mode": {
|
83
|
+
"code": "Code",
|
84
|
+
"preview": "Preview"
|
85
|
+
},
|
86
|
+
"title": "HTML Preview"
|
87
|
+
},
|
76
88
|
"ImageUpload": {
|
77
89
|
"actions": {
|
78
90
|
"changeImage": "Click to change image",
|
@@ -73,6 +73,18 @@
|
|
73
73
|
"GoBack": {
|
74
74
|
"back": "Regresar"
|
75
75
|
},
|
76
|
+
"HtmlPreview": {
|
77
|
+
"actions": {
|
78
|
+
"download": "Descargar",
|
79
|
+
"preview": "Vista previa"
|
80
|
+
},
|
81
|
+
"iframeTitle": "Vista previa HTML",
|
82
|
+
"mode": {
|
83
|
+
"code": "Código",
|
84
|
+
"preview": "Vista previa"
|
85
|
+
},
|
86
|
+
"title": "Vista previa HTML"
|
87
|
+
},
|
76
88
|
"ImageUpload": {
|
77
89
|
"actions": {
|
78
90
|
"changeImage": "Haz clic para cambiar la imagen",
|
@@ -73,6 +73,18 @@
|
|
73
73
|
"GoBack": {
|
74
74
|
"back": "بازگشت"
|
75
75
|
},
|
76
|
+
"HtmlPreview": {
|
77
|
+
"actions": {
|
78
|
+
"download": "دانلود",
|
79
|
+
"preview": "پیشنمایش"
|
80
|
+
},
|
81
|
+
"iframeTitle": "پیشنمایش HTML",
|
82
|
+
"mode": {
|
83
|
+
"code": "کد",
|
84
|
+
"preview": "پیشنمایش"
|
85
|
+
},
|
86
|
+
"title": "پیشنمایش HTML"
|
87
|
+
},
|
76
88
|
"ImageUpload": {
|
77
89
|
"actions": {
|
78
90
|
"changeImage": "برای تغییر تصویر کلیک کنید",
|
@@ -73,6 +73,18 @@
|
|
73
73
|
"GoBack": {
|
74
74
|
"back": "Retour"
|
75
75
|
},
|
76
|
+
"HtmlPreview": {
|
77
|
+
"actions": {
|
78
|
+
"download": "Télécharger",
|
79
|
+
"preview": "Aperçu"
|
80
|
+
},
|
81
|
+
"iframeTitle": "Aperçu HTML",
|
82
|
+
"mode": {
|
83
|
+
"code": "Code",
|
84
|
+
"preview": "Aperçu"
|
85
|
+
},
|
86
|
+
"title": "Aperçu HTML"
|
87
|
+
},
|
76
88
|
"ImageUpload": {
|
77
89
|
"actions": {
|
78
90
|
"changeImage": "Cliquez pour changer l'image",
|
@@ -73,6 +73,18 @@
|
|
73
73
|
"GoBack": {
|
74
74
|
"back": "Indietro"
|
75
75
|
},
|
76
|
+
"HtmlPreview": {
|
77
|
+
"actions": {
|
78
|
+
"download": "Scarica",
|
79
|
+
"preview": "Anteprima"
|
80
|
+
},
|
81
|
+
"iframeTitle": "Anteprima HTML",
|
82
|
+
"mode": {
|
83
|
+
"code": "Codice",
|
84
|
+
"preview": "Anteprima"
|
85
|
+
},
|
86
|
+
"title": "Anteprima HTML"
|
87
|
+
},
|
76
88
|
"ImageUpload": {
|
77
89
|
"actions": {
|
78
90
|
"changeImage": "Clicca per cambiare immagine",
|
@@ -73,6 +73,18 @@
|
|
73
73
|
"GoBack": {
|
74
74
|
"back": "戻る"
|
75
75
|
},
|
76
|
+
"HtmlPreview": {
|
77
|
+
"actions": {
|
78
|
+
"download": "ダウンロード",
|
79
|
+
"preview": "プレビュー"
|
80
|
+
},
|
81
|
+
"iframeTitle": "HTML プレビュー",
|
82
|
+
"mode": {
|
83
|
+
"code": "コード",
|
84
|
+
"preview": "プレビュー"
|
85
|
+
},
|
86
|
+
"title": "HTML プレビュー"
|
87
|
+
},
|
76
88
|
"ImageUpload": {
|
77
89
|
"actions": {
|
78
90
|
"changeImage": "画像を変更するにはクリックしてください",
|
@@ -73,6 +73,18 @@
|
|
73
73
|
"GoBack": {
|
74
74
|
"back": "뒤로 가기"
|
75
75
|
},
|
76
|
+
"HtmlPreview": {
|
77
|
+
"actions": {
|
78
|
+
"download": "다운로드",
|
79
|
+
"preview": "미리보기"
|
80
|
+
},
|
81
|
+
"iframeTitle": "HTML 미리보기",
|
82
|
+
"mode": {
|
83
|
+
"code": "코드",
|
84
|
+
"preview": "미리보기"
|
85
|
+
},
|
86
|
+
"title": "HTML 미리보기"
|
87
|
+
},
|
76
88
|
"ImageUpload": {
|
77
89
|
"actions": {
|
78
90
|
"changeImage": "이미지 변경 클릭",
|
@@ -73,6 +73,18 @@
|
|
73
73
|
"GoBack": {
|
74
74
|
"back": "Terug"
|
75
75
|
},
|
76
|
+
"HtmlPreview": {
|
77
|
+
"actions": {
|
78
|
+
"download": "Downloaden",
|
79
|
+
"preview": "Voorbeeld"
|
80
|
+
},
|
81
|
+
"iframeTitle": "HTML Voorbeeld",
|
82
|
+
"mode": {
|
83
|
+
"code": "Code",
|
84
|
+
"preview": "Voorbeeld"
|
85
|
+
},
|
86
|
+
"title": "HTML Voorbeeld"
|
87
|
+
},
|
76
88
|
"ImageUpload": {
|
77
89
|
"actions": {
|
78
90
|
"changeImage": "Klik om afbeelding te wijzigen",
|
@@ -73,6 +73,18 @@
|
|
73
73
|
"GoBack": {
|
74
74
|
"back": "Wróć"
|
75
75
|
},
|
76
|
+
"HtmlPreview": {
|
77
|
+
"actions": {
|
78
|
+
"download": "Pobierz",
|
79
|
+
"preview": "Podgląd"
|
80
|
+
},
|
81
|
+
"iframeTitle": "Podgląd HTML",
|
82
|
+
"mode": {
|
83
|
+
"code": "Kod",
|
84
|
+
"preview": "Podgląd"
|
85
|
+
},
|
86
|
+
"title": "Podgląd HTML"
|
87
|
+
},
|
76
88
|
"ImageUpload": {
|
77
89
|
"actions": {
|
78
90
|
"changeImage": "Kliknij, aby zmienić obraz",
|
@@ -73,6 +73,18 @@
|
|
73
73
|
"GoBack": {
|
74
74
|
"back": "Voltar"
|
75
75
|
},
|
76
|
+
"HtmlPreview": {
|
77
|
+
"actions": {
|
78
|
+
"download": "Baixar",
|
79
|
+
"preview": "Visualizar"
|
80
|
+
},
|
81
|
+
"iframeTitle": "Visualização HTML",
|
82
|
+
"mode": {
|
83
|
+
"code": "Código",
|
84
|
+
"preview": "Visualizar"
|
85
|
+
},
|
86
|
+
"title": "Visualização HTML"
|
87
|
+
},
|
76
88
|
"ImageUpload": {
|
77
89
|
"actions": {
|
78
90
|
"changeImage": "Clique para alterar a imagem",
|
@@ -73,6 +73,18 @@
|
|
73
73
|
"GoBack": {
|
74
74
|
"back": "Назад"
|
75
75
|
},
|
76
|
+
"HtmlPreview": {
|
77
|
+
"actions": {
|
78
|
+
"download": "Скачать",
|
79
|
+
"preview": "Предпросмотр"
|
80
|
+
},
|
81
|
+
"iframeTitle": "Предпросмотр HTML",
|
82
|
+
"mode": {
|
83
|
+
"code": "Код",
|
84
|
+
"preview": "Предпросмотр"
|
85
|
+
},
|
86
|
+
"title": "Предпросмотр HTML"
|
87
|
+
},
|
76
88
|
"ImageUpload": {
|
77
89
|
"actions": {
|
78
90
|
"changeImage": "Нажмите, чтобы изменить изображение",
|
@@ -73,6 +73,18 @@
|
|
73
73
|
"GoBack": {
|
74
74
|
"back": "Geri dön"
|
75
75
|
},
|
76
|
+
"HtmlPreview": {
|
77
|
+
"actions": {
|
78
|
+
"download": "İndir",
|
79
|
+
"preview": "Önizleme"
|
80
|
+
},
|
81
|
+
"iframeTitle": "HTML Önizlemesi",
|
82
|
+
"mode": {
|
83
|
+
"code": "Kod",
|
84
|
+
"preview": "Önizleme"
|
85
|
+
},
|
86
|
+
"title": "HTML Önizlemesi"
|
87
|
+
},
|
76
88
|
"ImageUpload": {
|
77
89
|
"actions": {
|
78
90
|
"changeImage": "Resmi değiştirmek için tıklayın",
|
@@ -73,6 +73,18 @@
|
|
73
73
|
"GoBack": {
|
74
74
|
"back": "Quay lại"
|
75
75
|
},
|
76
|
+
"HtmlPreview": {
|
77
|
+
"actions": {
|
78
|
+
"download": "Tải xuống",
|
79
|
+
"preview": "Xem trước"
|
80
|
+
},
|
81
|
+
"iframeTitle": "Xem trước HTML",
|
82
|
+
"mode": {
|
83
|
+
"code": "Mã",
|
84
|
+
"preview": "Xem trước"
|
85
|
+
},
|
86
|
+
"title": "Xem trước HTML"
|
87
|
+
},
|
76
88
|
"ImageUpload": {
|
77
89
|
"actions": {
|
78
90
|
"changeImage": "Nhấn để thay đổi hình ảnh",
|
@@ -73,6 +73,18 @@
|
|
73
73
|
"GoBack": {
|
74
74
|
"back": "返回"
|
75
75
|
},
|
76
|
+
"HtmlPreview": {
|
77
|
+
"actions": {
|
78
|
+
"download": "下载",
|
79
|
+
"preview": "预览"
|
80
|
+
},
|
81
|
+
"iframeTitle": "HTML 预览",
|
82
|
+
"mode": {
|
83
|
+
"code": "代码",
|
84
|
+
"preview": "预览"
|
85
|
+
},
|
86
|
+
"title": "HTML 预览"
|
87
|
+
},
|
76
88
|
"ImageUpload": {
|
77
89
|
"actions": {
|
78
90
|
"changeImage": "点击更换图片",
|
@@ -73,6 +73,18 @@
|
|
73
73
|
"GoBack": {
|
74
74
|
"back": "返回"
|
75
75
|
},
|
76
|
+
"HtmlPreview": {
|
77
|
+
"actions": {
|
78
|
+
"download": "下載",
|
79
|
+
"preview": "預覽"
|
80
|
+
},
|
81
|
+
"iframeTitle": "HTML 預覽",
|
82
|
+
"mode": {
|
83
|
+
"code": "程式碼",
|
84
|
+
"preview": "預覽"
|
85
|
+
},
|
86
|
+
"title": "HTML 預覽"
|
87
|
+
},
|
76
88
|
"ImageUpload": {
|
77
89
|
"actions": {
|
78
90
|
"changeImage": "點擊更換圖片",
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@lobehub/chat",
|
3
|
-
"version": "1.116.
|
3
|
+
"version": "1.116.4",
|
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",
|
@@ -183,7 +183,7 @@
|
|
183
183
|
"dayjs": "^1.11.13",
|
184
184
|
"debug": "^4.4.1",
|
185
185
|
"dexie": "^3.2.7",
|
186
|
-
"diff": "^
|
186
|
+
"diff": "^8.0.0",
|
187
187
|
"drizzle-orm": "^0.44.4",
|
188
188
|
"drizzle-zod": "^0.5.1",
|
189
189
|
"epub2": "^3.0.2",
|
@@ -300,7 +300,7 @@
|
|
300
300
|
"@types/chroma-js": "^3.1.1",
|
301
301
|
"@types/crypto-js": "^4.2.2",
|
302
302
|
"@types/debug": "^4.1.12",
|
303
|
-
"@types/diff": "^
|
303
|
+
"@types/diff": "^8.0.0",
|
304
304
|
"@types/fs-extra": "^11.0.4",
|
305
305
|
"@types/ip": "^1.1.3",
|
306
306
|
"@types/json-schema": "^7.0.15",
|
@@ -324,10 +324,10 @@
|
|
324
324
|
"ajv-keywords": "^5.1.0",
|
325
325
|
"commitlint": "^19.8.1",
|
326
326
|
"consola": "^3.4.2",
|
327
|
-
"cross-env": "^
|
327
|
+
"cross-env": "^10.0.0",
|
328
328
|
"crypto-js": "^4.2.0",
|
329
329
|
"dbdocs": "^0.16.0",
|
330
|
-
"dotenv": "^
|
330
|
+
"dotenv": "^17.0.0",
|
331
331
|
"dpdm-fast": "1.0.7",
|
332
332
|
"drizzle-dbml-generator": "^0.10.0",
|
333
333
|
"drizzle-kit": "^0.31.4",
|
@@ -1,5 +1,6 @@
|
|
1
|
-
import {
|
2
|
-
|
1
|
+
import { MetaData } from '@lobechat/types';
|
2
|
+
|
3
|
+
import { BRANDING_LOGO_URL } from './branding';
|
3
4
|
|
4
5
|
export const DEFAULT_AVATAR = '🤖';
|
5
6
|
export const DEFAULT_USER_AVATAR = '😀';
|
@@ -1,7 +1,12 @@
|
|
1
|
-
import {
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
import {
|
2
|
+
LobeAgentChatConfig,
|
3
|
+
LobeAgentConfig,
|
4
|
+
LobeAgentTTSConfig,
|
5
|
+
UserDefaultAgent,
|
6
|
+
} from '@lobechat/types';
|
7
|
+
|
8
|
+
import { DEFAULT_AGENT_META } from '../meta';
|
9
|
+
import { DEFAULT_MODEL, DEFAULT_PROVIDER } from './llm';
|
5
10
|
|
6
11
|
export const DEFAUTT_AGENT_TTS_CONFIG: LobeAgentTTSConfig = {
|
7
12
|
showAllLocaleVoice: false,
|
@@ -6,9 +6,6 @@ import {
|
|
6
6
|
|
7
7
|
import { DEFAULT_MODEL, DEFAULT_PROVIDER } from './llm';
|
8
8
|
|
9
|
-
export const DEFAULT_REWRITE_QUERY =
|
10
|
-
'Given the following conversation and a follow-up question, rephrase the follow up question to be a standalone question, in its original language. Keep as much details as possible from previous messages. Keep entity names and all.';
|
11
|
-
|
12
9
|
export const DEFAULT_SYSTEM_AGENT_ITEM: SystemAgentItem = {
|
13
10
|
model: DEFAULT_MODEL,
|
14
11
|
provider: DEFAULT_PROVIDER,
|
@@ -2,13 +2,9 @@ import { defineConfig } from 'vitest/config';
|
|
2
2
|
|
3
3
|
export default defineConfig({
|
4
4
|
test: {
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
// reporter: ['text', 'json', 'lcov', 'text-summary'],
|
9
|
-
// reportsDirectory: './coverage/app',
|
10
|
-
// },
|
5
|
+
coverage: {
|
6
|
+
reporter: ['text', 'json', 'lcov', 'text-summary'],
|
7
|
+
},
|
11
8
|
environment: 'happy-dom',
|
12
|
-
// setupFiles: join(__dirname, './test/setup.ts'),
|
13
9
|
},
|
14
10
|
});
|
@@ -0,0 +1,52 @@
|
|
1
|
+
import { describe, expect, it, vi } from 'vitest';
|
2
|
+
|
3
|
+
import { chainAbstractChunkText } from '../abstractChunk';
|
4
|
+
|
5
|
+
describe('chainAbstractChunkText', () => {
|
6
|
+
it('should generate correct chat payload for chunk text', () => {
|
7
|
+
const testText = 'This is a sample chunk of text that needs to be summarized.';
|
8
|
+
|
9
|
+
const result = chainAbstractChunkText(testText);
|
10
|
+
|
11
|
+
expect(result).toEqual({
|
12
|
+
messages: [
|
13
|
+
{
|
14
|
+
content:
|
15
|
+
'你是一名擅长从 chunk 中提取摘要的助理,你需要将用户的会话总结为 1~2 句话的摘要,输出成 chunk 所使用的语种',
|
16
|
+
role: 'system',
|
17
|
+
},
|
18
|
+
{
|
19
|
+
content: `chunk: ${testText}`,
|
20
|
+
role: 'user',
|
21
|
+
},
|
22
|
+
],
|
23
|
+
});
|
24
|
+
});
|
25
|
+
|
26
|
+
it('should handle empty text', () => {
|
27
|
+
const result = chainAbstractChunkText('');
|
28
|
+
|
29
|
+
expect(result.messages).toHaveLength(2);
|
30
|
+
expect(result.messages![1].content).toBe('chunk: ');
|
31
|
+
});
|
32
|
+
|
33
|
+
it('should handle text with special characters', () => {
|
34
|
+
const testText = 'Text with special chars: @#$%^&*()';
|
35
|
+
|
36
|
+
const result = chainAbstractChunkText(testText);
|
37
|
+
|
38
|
+
expect(result.messages![1].content).toBe(`chunk: ${testText}`);
|
39
|
+
});
|
40
|
+
|
41
|
+
it('should always use system role for first message', () => {
|
42
|
+
const result = chainAbstractChunkText('test');
|
43
|
+
|
44
|
+
expect(result.messages![0].role).toBe('system');
|
45
|
+
});
|
46
|
+
|
47
|
+
it('should always use user role for second message', () => {
|
48
|
+
const result = chainAbstractChunkText('test');
|
49
|
+
|
50
|
+
expect(result.messages![1].role).toBe('user');
|
51
|
+
});
|
52
|
+
});
|