@lobehub/chat 1.26.19 → 1.26.20
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 +25 -0
- package/locales/ar/components.json +1 -0
- package/locales/bg-BG/components.json +1 -0
- package/locales/de-DE/components.json +1 -0
- package/locales/en-US/components.json +1 -0
- package/locales/es-ES/components.json +1 -0
- package/locales/fr-FR/components.json +1 -0
- package/locales/it-IT/components.json +1 -0
- package/locales/ja-JP/components.json +1 -0
- package/locales/ko-KR/components.json +1 -0
- package/locales/nl-NL/components.json +1 -0
- package/locales/pl-PL/components.json +1 -0
- package/locales/pt-BR/components.json +1 -0
- package/locales/ru-RU/components.json +1 -0
- package/locales/tr-TR/components.json +1 -0
- package/locales/vi-VN/components.json +1 -0
- package/locales/zh-CN/components.json +1 -0
- package/locales/zh-TW/components.json +1 -0
- package/package.json +1 -1
- package/src/features/FileManager/FileList/FileListItem/index.tsx +9 -1
- package/src/features/FileManager/FileList/ToolBar/index.tsx +8 -2
- package/src/locales/default/components.ts +1 -0
- package/src/store/file/slices/chat/action.ts +2 -1
- package/src/utils/isChunkingUnsupported.test.ts +43 -0
- package/src/utils/isChunkingUnsupported.ts +6 -0
package/CHANGELOG.md
CHANGED
@@ -2,6 +2,31 @@
|
|
2
2
|
|
3
3
|
# Changelog
|
4
4
|
|
5
|
+
### [Version 1.26.20](https://github.com/lobehub/lobe-chat/compare/v1.26.19...v1.26.20)
|
6
|
+
|
7
|
+
<sup>Released on **2024-11-04**</sup>
|
8
|
+
|
9
|
+
#### 💄 Styles
|
10
|
+
|
11
|
+
- **misc**: Disable chunking button for unsupported files.
|
12
|
+
|
13
|
+
<br/>
|
14
|
+
|
15
|
+
<details>
|
16
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
17
|
+
|
18
|
+
#### Styles
|
19
|
+
|
20
|
+
- **misc**: Disable chunking button for unsupported files, closes [#4153](https://github.com/lobehub/lobe-chat/issues/4153) ([87ac46d](https://github.com/lobehub/lobe-chat/commit/87ac46d))
|
21
|
+
|
22
|
+
</details>
|
23
|
+
|
24
|
+
<div align="right">
|
25
|
+
|
26
|
+
[](#readme-top)
|
27
|
+
|
28
|
+
</div>
|
29
|
+
|
5
30
|
### [Version 1.26.19](https://github.com/lobehub/lobe-chat/compare/v1.26.18...v1.26.19)
|
6
31
|
|
7
32
|
<sup>Released on **2024-11-03**</sup>
|
@@ -12,6 +12,7 @@
|
|
12
12
|
"batchChunking": "تقسيم دفعي",
|
13
13
|
"chunking": "تقسيم",
|
14
14
|
"chunkingTooltip": "قم بتقسيم الملف إلى عدة كتل نصية وتحويلها إلى متجهات، يمكن استخدامها في البحث الدلالي والمحادثة حول الملفات",
|
15
|
+
"chunkingUnsupported": "هذا الملف لا يدعم تقسيم الأجزاء",
|
15
16
|
"confirmDelete": "سيتم حذف هذا الملف، ولن يمكن استعادته بعد الحذف، يرجى تأكيد العملية",
|
16
17
|
"confirmDeleteMultiFiles": "سيتم حذف {{count}} ملفًا محددًا، ولن يمكن استعادته بعد الحذف، يرجى تأكيد العملية",
|
17
18
|
"confirmRemoveFromKnowledgeBase": "سيتم إزالة {{count}} ملفًا محددًا من قاعدة المعرفة، لا يزال بإمكانك رؤية الملفات في جميع الملفات، يرجى تأكيد العملية",
|
@@ -12,6 +12,7 @@
|
|
12
12
|
"batchChunking": "Партидно разделяне",
|
13
13
|
"chunking": "Разделяне",
|
14
14
|
"chunkingTooltip": "Разделете файла на множество текстови блокове и ги векторизирайте, за да се използват за семантично търсене и диалог с файла",
|
15
|
+
"chunkingUnsupported": "Този файл не поддържа разделяне на части.",
|
15
16
|
"confirmDelete": "Ще изтриете този файл. След изтриването му няма да може да бъде възстановен. Моля, потвърдете действието си.",
|
16
17
|
"confirmDeleteMultiFiles": "Ще изтриете избраните {{count}} файла. След изтриването им няма да могат да бъдат възстановени. Моля, потвърдете действието си.",
|
17
18
|
"confirmRemoveFromKnowledgeBase": "Ще премахнете избраните {{count}} файла от базата знания. След премахването им файловете все още могат да бъдат видяни в списъка с всички файлове. Моля, потвърдете действието си.",
|
@@ -12,6 +12,7 @@
|
|
12
12
|
"batchChunking": "Batch-Zerteilung",
|
13
13
|
"chunking": "Zerteilung",
|
14
14
|
"chunkingTooltip": "Teilen Sie die Datei in mehrere Textblöcke und vektorisieren Sie sie, um sie für die semantische Suche und Dateidialoge zu verwenden.",
|
15
|
+
"chunkingUnsupported": "Diese Datei unterstützt kein Chunking.",
|
15
16
|
"confirmDelete": "Die Datei wird gelöscht. Nach dem Löschen kann sie nicht wiederhergestellt werden. Bitte bestätigen Sie Ihre Aktion.",
|
16
17
|
"confirmDeleteMultiFiles": "Die ausgewählten {{count}} Dateien werden gelöscht. Nach dem Löschen können sie nicht wiederhergestellt werden. Bitte bestätigen Sie Ihre Aktion.",
|
17
18
|
"confirmRemoveFromKnowledgeBase": "Die ausgewählten {{count}} Dateien werden aus der Wissensdatenbank entfernt. Die Dateien sind weiterhin in allen Dateien sichtbar. Bitte bestätigen Sie Ihre Aktion.",
|
@@ -12,6 +12,7 @@
|
|
12
12
|
"batchChunking": "Batch Chunking",
|
13
13
|
"chunking": "Chunking",
|
14
14
|
"chunkingTooltip": "Split the file into multiple text chunks and embedding them for semantic search and file dialogue.",
|
15
|
+
"chunkingUnsupported": "This file does not support chunking.",
|
15
16
|
"confirmDelete": "You are about to delete this file. Once deleted, it cannot be recovered. Please confirm your action.",
|
16
17
|
"confirmDeleteMultiFiles": "You are about to delete the selected {{count}} files. Once deleted, they cannot be recovered. Please confirm your action.",
|
17
18
|
"confirmRemoveFromKnowledgeBase": "You are about to remove the selected {{count}} files from the knowledge base. They will still be viewable in all files. Please confirm your action.",
|
@@ -12,6 +12,7 @@
|
|
12
12
|
"batchChunking": "División por lotes",
|
13
13
|
"chunking": "División",
|
14
14
|
"chunkingTooltip": "Divida el archivo en múltiples bloques de texto y vectorícelos para su uso en búsqueda semántica y diálogo de archivos",
|
15
|
+
"chunkingUnsupported": "Este archivo no admite la fragmentación",
|
15
16
|
"confirmDelete": "Está a punto de eliminar este archivo. Una vez eliminado, no podrá recuperarlo. Por favor, confirme su acción.",
|
16
17
|
"confirmDeleteMultiFiles": "Está a punto de eliminar los {{count}} archivos seleccionados. Una vez eliminados, no podrá recuperarlos. Por favor, confirme su acción.",
|
17
18
|
"confirmRemoveFromKnowledgeBase": "Está a punto de eliminar los {{count}} archivos seleccionados de la base de conocimientos. Los archivos seguirán siendo visibles en todos los archivos. Por favor, confirme su acción.",
|
@@ -12,6 +12,7 @@
|
|
12
12
|
"batchChunking": "Découpage par lots",
|
13
13
|
"chunking": "Découpage",
|
14
14
|
"chunkingTooltip": "Divisez le fichier en plusieurs blocs de texte et vectorisez-les pour une recherche sémantique et un dialogue sur le fichier",
|
15
|
+
"chunkingUnsupported": "Ce fichier ne prend pas en charge le fractionnement",
|
15
16
|
"confirmDelete": "Vous allez supprimer ce fichier. Une fois supprimé, il ne pourra pas être récupéré. Veuillez confirmer votre action.",
|
16
17
|
"confirmDeleteMultiFiles": "Vous allez supprimer les {{count}} fichiers sélectionnés. Une fois supprimés, ils ne pourront pas être récupérés. Veuillez confirmer votre action.",
|
17
18
|
"confirmRemoveFromKnowledgeBase": "Vous allez retirer les {{count}} fichiers sélectionnés de la base de connaissances. Une fois retirés, les fichiers resteront visibles dans tous les fichiers. Veuillez confirmer votre action.",
|
@@ -12,6 +12,7 @@
|
|
12
12
|
"batchChunking": "Suddivisione in batch",
|
13
13
|
"chunking": "Suddivisione",
|
14
14
|
"chunkingTooltip": "Dividi il file in più blocchi di testo e vettorizzali, utilizzabili per la ricerca semantica e il dialogo sui file",
|
15
|
+
"chunkingUnsupported": "Questo file non supporta il frazionamento",
|
15
16
|
"confirmDelete": "Stai per eliminare questo file. Una volta eliminato, non sarà possibile recuperarlo. Ti preghiamo di confermare l'operazione.",
|
16
17
|
"confirmDeleteMultiFiles": "Stai per eliminare i {{count}} file selezionati. Una volta eliminati, non sarà possibile recuperarli. Ti preghiamo di confermare l'operazione.",
|
17
18
|
"confirmRemoveFromKnowledgeBase": "Stai per rimuovere i {{count}} file selezionati dalla base di conoscenza. I file rimarranno visibili in tutti i file. Ti preghiamo di confermare l'operazione.",
|
@@ -12,6 +12,7 @@
|
|
12
12
|
"batchChunking": "バッチ分割",
|
13
13
|
"chunking": "分割",
|
14
14
|
"chunkingTooltip": "ファイルを複数のテキストブロックに分割し、ベクトル化した後、意味検索やファイル対話に使用できます",
|
15
|
+
"chunkingUnsupported": "このファイルはチャンク分割をサポートしていません",
|
15
16
|
"confirmDelete": "このファイルを削除しようとしています。削除後は復元できませんので、操作を確認してください",
|
16
17
|
"confirmDeleteMultiFiles": "選択した {{count}} 個のファイルを削除しようとしています。削除後は復元できませんので、操作を確認してください",
|
17
18
|
"confirmRemoveFromKnowledgeBase": "選択した {{count}} 個のファイルを知識ベースから削除しようとしています。削除後もファイルはすべてのファイルで表示できますので、操作を確認してください",
|
@@ -12,6 +12,7 @@
|
|
12
12
|
"batchChunking": "배치 청크 분할",
|
13
13
|
"chunking": "청크 분할",
|
14
14
|
"chunkingTooltip": "파일을 여러 텍스트 블록으로 분할하고 벡터화한 후, 의미 검색 및 파일 대화에 사용할 수 있습니다.",
|
15
|
+
"chunkingUnsupported": "이 파일은 청크 처리를 지원하지 않습니다.",
|
15
16
|
"confirmDelete": "해당 파일을 삭제하려고 합니다. 삭제 후에는 복구할 수 없으니, 작업을 확인해 주세요.",
|
16
17
|
"confirmDeleteMultiFiles": "선택한 {{count}} 개 파일을 삭제하려고 합니다. 삭제 후에는 복구할 수 없으니, 작업을 확인해 주세요.",
|
17
18
|
"confirmRemoveFromKnowledgeBase": "선택한 {{count}} 개 파일을 지식 베이스에서 제거하려고 합니다. 제거 후에도 파일은 모든 파일에서 볼 수 있으니, 작업을 확인해 주세요.",
|
@@ -12,6 +12,7 @@
|
|
12
12
|
"batchChunking": "Batchverdeling",
|
13
13
|
"chunking": "Verdeling",
|
14
14
|
"chunkingTooltip": "Splits het bestand in meerdere tekstblokken en vectoriseer deze voor semantische zoekopdrachten en bestandsdialoog",
|
15
|
+
"chunkingUnsupported": "Dit bestand ondersteunt geen chunking",
|
15
16
|
"confirmDelete": "Je staat op het punt dit bestand te verwijderen. Na verwijdering kan het niet meer worden hersteld. Bevestig je actie.",
|
16
17
|
"confirmDeleteMultiFiles": "Je staat op het punt de geselecteerde {{count}} bestanden te verwijderen. Na verwijdering kunnen ze niet meer worden hersteld. Bevestig je actie.",
|
17
18
|
"confirmRemoveFromKnowledgeBase": "Je staat op het punt de geselecteerde {{count}} bestanden uit de kennisbank te verwijderen. Na verwijdering zijn de bestanden nog steeds zichtbaar in alle bestanden. Bevestig je actie.",
|
@@ -12,6 +12,7 @@
|
|
12
12
|
"batchChunking": "Partycjonowanie wsadowe",
|
13
13
|
"chunking": "Partycjonowanie",
|
14
14
|
"chunkingTooltip": "Podziel plik na wiele bloków tekstowych i wektoryzuj, aby umożliwić wyszukiwanie semantyczne i rozmowy o plikach",
|
15
|
+
"chunkingUnsupported": "Ten plik nie obsługuje podziału na części.",
|
15
16
|
"confirmDelete": "Zaraz usuniesz ten plik. Po usunięciu nie będzie można go odzyskać, proszę potwierdź swoje działanie",
|
16
17
|
"confirmDeleteMultiFiles": "Zaraz usuniesz wybrane {{count}} plików. Po usunięciu nie będzie można ich odzyskać, proszę potwierdź swoje działanie",
|
17
18
|
"confirmRemoveFromKnowledgeBase": "Zaraz usuniesz wybrane {{count}} plików z bazy wiedzy. Po usunięciu pliki będą nadal widoczne wśród wszystkich plików, proszę potwierdź swoje działanie",
|
@@ -12,6 +12,7 @@
|
|
12
12
|
"batchChunking": "Divisão em lotes",
|
13
13
|
"chunking": "Divisão",
|
14
14
|
"chunkingTooltip": "Divida o arquivo em vários blocos de texto e vetorize, podendo ser usado para busca semântica e diálogo sobre o arquivo",
|
15
|
+
"chunkingUnsupported": "Este arquivo não suporta divisão em partes.",
|
15
16
|
"confirmDelete": "Você está prestes a excluir este arquivo. Após a exclusão, ele não poderá ser recuperado. Por favor, confirme sua ação.",
|
16
17
|
"confirmDeleteMultiFiles": "Você está prestes a excluir {{count}} arquivos selecionados. Após a exclusão, eles não poderão ser recuperados. Por favor, confirme sua ação.",
|
17
18
|
"confirmRemoveFromKnowledgeBase": "Você está prestes a remover {{count}} arquivos selecionados do banco de conhecimento. Após a remoção, os arquivos ainda poderão ser visualizados em todos os arquivos. Por favor, confirme sua ação.",
|
@@ -12,6 +12,7 @@
|
|
12
12
|
"batchChunking": "Пакетная разбивка",
|
13
13
|
"chunking": "Разбивка",
|
14
14
|
"chunkingTooltip": "Разделите файл на несколько текстовых блоков и векторизуйте их для семантического поиска и диалога с файлом",
|
15
|
+
"chunkingUnsupported": "Этот файл не поддерживает разбиение на части",
|
15
16
|
"confirmDelete": "Вы собираетесь удалить этот файл. После удаления его нельзя будет восстановить. Пожалуйста, подтвердите ваше действие.",
|
16
17
|
"confirmDeleteMultiFiles": "Вы собираетесь удалить выбранные {{count}} файлов. После удаления их нельзя будет восстановить. Пожалуйста, подтвердите ваше действие.",
|
17
18
|
"confirmRemoveFromKnowledgeBase": "Вы собираетесь удалить выбранные {{count}} файлов из базы знаний. После удаления файлы все еще будут доступны во всех файлах. Пожалуйста, подтвердите ваше действие.",
|
@@ -12,6 +12,7 @@
|
|
12
12
|
"batchChunking": "Toplu parçalara ayırma",
|
13
13
|
"chunking": "Parçalara ayırma",
|
14
14
|
"chunkingTooltip": "Dosyayı birden fazla metin parçasına ayırıp vektörleştirdikten sonra, anlamsal arama ve dosya diyalogları için kullanılabilir",
|
15
|
+
"chunkingUnsupported": "Bu dosya parça parça yüklemeyi desteklemiyor.",
|
15
16
|
"confirmDelete": "Bu dosya silinecek, silindikten sonra geri alınamaz, lütfen işleminizi onaylayın",
|
16
17
|
"confirmDeleteMultiFiles": "Seçilen {{count}} dosya silinecek, silindikten sonra geri alınamaz, lütfen işleminizi onaylayın",
|
17
18
|
"confirmRemoveFromKnowledgeBase": "Seçilen {{count}} dosya bilgi tabanından kaldırılacak, kaldırıldıktan sonra dosyalar tüm dosyalar arasında görüntülenebilir, lütfen işleminizi onaylayın",
|
@@ -12,6 +12,7 @@
|
|
12
12
|
"batchChunking": "Chia nhỏ theo lô",
|
13
13
|
"chunking": "Chia nhỏ",
|
14
14
|
"chunkingTooltip": "Chia tách tệp thành nhiều khối văn bản và vector hóa, có thể sử dụng cho tìm kiếm ngữ nghĩa và đối thoại tệp",
|
15
|
+
"chunkingUnsupported": "Tập tin này không hỗ trợ phân mảnh",
|
15
16
|
"confirmDelete": "Bạn sắp xóa tệp này, sau khi xóa sẽ không thể khôi phục, vui lòng xác nhận hành động của bạn",
|
16
17
|
"confirmDeleteMultiFiles": "Bạn sắp xóa {{count}} tệp đã chọn, sau khi xóa sẽ không thể khôi phục, vui lòng xác nhận hành động của bạn",
|
17
18
|
"confirmRemoveFromKnowledgeBase": "Bạn sắp xóa {{count}} tệp đã chọn khỏi kho tri thức, sau khi xóa tệp vẫn có thể xem trong tất cả các tệp, vui lòng xác nhận hành động của bạn",
|
@@ -12,6 +12,7 @@
|
|
12
12
|
"batchChunking": "批量分块",
|
13
13
|
"chunking": "分块",
|
14
14
|
"chunkingTooltip": "将文件拆分为多个文本块并向量化后,可用于语义检索和文件对话",
|
15
|
+
"chunkingUnsupported": "该文件不支持分块",
|
15
16
|
"confirmDelete": "即将删除该文件,删除后该将无法找回,请确认你的操作",
|
16
17
|
"confirmDeleteMultiFiles": "即将删除选中的 {{count}} 个文件,删除后该将无法找回,请确认你的操作",
|
17
18
|
"confirmRemoveFromKnowledgeBase": "即将从知识库中移除选中的 {{count}} 个文件,移除后文件仍然可以在全部文件中查看,请确认你的操作",
|
@@ -12,6 +12,7 @@
|
|
12
12
|
"batchChunking": "批量分塊",
|
13
13
|
"chunking": "分塊",
|
14
14
|
"chunkingTooltip": "將文件拆分為多個文本塊並向量化後,可用於語義檢索和文件對話",
|
15
|
+
"chunkingUnsupported": "該檔案不支援分塊",
|
15
16
|
"confirmDelete": "即將刪除該文件,刪除後將無法找回,請確認你的操作",
|
16
17
|
"confirmDeleteMultiFiles": "即將刪除選中的 {{count}} 個文件,刪除後將無法找回,請確認你的操作",
|
17
18
|
"confirmRemoveFromKnowledgeBase": "即將從知識庫中移除選中的 {{count}} 個文件,移除後文件仍然可以在全部文件中查看,請確認你的操作",
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@lobehub/chat",
|
3
|
-
"version": "1.26.
|
3
|
+
"version": "1.26.20",
|
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,6 +15,7 @@ import FileIcon from '@/components/FileIcon';
|
|
15
15
|
import { fileManagerSelectors, useFileStore } from '@/store/file';
|
16
16
|
import { FileListItem } from '@/types/files';
|
17
17
|
import { formatSize } from '@/utils/format';
|
18
|
+
import { isChunkingUnsupported } from '@/utils/isChunkingUnsupported';
|
18
19
|
|
19
20
|
import ChunksBadge from './ChunkTag';
|
20
21
|
import DropdownMenu from './DropdownMenu';
|
@@ -107,6 +108,8 @@ const FileRenderItem = memo<FileRenderItemProps>(
|
|
107
108
|
s.parseFilesToChunks,
|
108
109
|
]);
|
109
110
|
|
111
|
+
const isSupportedForChunking = !isChunkingUnsupported(fileType);
|
112
|
+
|
110
113
|
const displayTime =
|
111
114
|
dayjs().diff(dayjs(createdAt), 'd') < 7
|
112
115
|
? dayjs(createdAt).fromNow()
|
@@ -160,9 +163,14 @@ const FileRenderItem = memo<FileRenderItemProps>(
|
|
160
163
|
<div className={isCreatingFileParseTask ? undefined : styles.hover}>
|
161
164
|
<Tooltip
|
162
165
|
overlayStyle={{ pointerEvents: 'none' }}
|
163
|
-
title={t(
|
166
|
+
title={t(
|
167
|
+
isSupportedForChunking
|
168
|
+
? 'FileManager.actions.chunkingTooltip'
|
169
|
+
: 'FileManager.actions.chunkingUnsupported',
|
170
|
+
)}
|
164
171
|
>
|
165
172
|
<Button
|
173
|
+
disabled={!isSupportedForChunking}
|
166
174
|
icon={<Icon icon={FileBoxIcon} />}
|
167
175
|
loading={isCreatingFileParseTask}
|
168
176
|
onClick={() => {
|
@@ -6,6 +6,7 @@ import { Flexbox } from 'react-layout-kit';
|
|
6
6
|
import { useAddFilesToKnowledgeBaseModal } from '@/features/KnowledgeBaseModal';
|
7
7
|
import { useFileStore } from '@/store/file';
|
8
8
|
import { useKnowledgeBaseStore } from '@/store/knowledgeBase';
|
9
|
+
import { isChunkingUnsupported } from '@/utils/isChunkingUnsupported';
|
9
10
|
|
10
11
|
import Config from './Config';
|
11
12
|
import MultiSelectActions, { MultiSelectActionType } from './MultiSelectActions';
|
@@ -44,9 +45,10 @@ const ToolBar = memo<MultiSelectActionsProps>(
|
|
44
45
|
}) => {
|
45
46
|
const { styles } = useStyles();
|
46
47
|
|
47
|
-
const [removeFiles, parseFilesToChunks] = useFileStore((s) => [
|
48
|
+
const [removeFiles, parseFilesToChunks, fileList] = useFileStore((s) => [
|
48
49
|
s.removeFiles,
|
49
50
|
s.parseFilesToChunks,
|
51
|
+
s.fileList,
|
50
52
|
]);
|
51
53
|
const [removeFromKnowledgeBase] = useKnowledgeBaseStore((s) => [
|
52
54
|
s.removeFilesFromKnowledgeBase,
|
@@ -86,7 +88,11 @@ const ToolBar = memo<MultiSelectActionsProps>(
|
|
86
88
|
}
|
87
89
|
|
88
90
|
case 'batchChunking': {
|
89
|
-
|
91
|
+
const chunkableFileIds = selectFileIds.filter((id) => {
|
92
|
+
const file = fileList.find((f) => f.id === id);
|
93
|
+
return file && !isChunkingUnsupported(file.fileType);
|
94
|
+
});
|
95
|
+
await parseFilesToChunks(chunkableFileIds, { skipExist: true });
|
90
96
|
setSelectedFileIds([]);
|
91
97
|
return;
|
92
98
|
}
|
@@ -12,6 +12,7 @@ export default {
|
|
12
12
|
batchChunking: '批量分块',
|
13
13
|
chunking: '分块',
|
14
14
|
chunkingTooltip: '将文件拆分为多个文本块并向量化后,可用于语义检索和文件对话',
|
15
|
+
chunkingUnsupported: '该文件不支持分块',
|
15
16
|
confirmDelete: '即将删除该文件,删除后该将无法找回,请确认你的操作',
|
16
17
|
confirmDeleteMultiFiles:
|
17
18
|
'即将删除选中的 {{count}} 个文件,删除后该将无法找回,请确认你的操作',
|
@@ -17,6 +17,7 @@ import { useUserStore } from '@/store/user';
|
|
17
17
|
import { preferenceSelectors } from '@/store/user/selectors';
|
18
18
|
import { FileListItem } from '@/types/files';
|
19
19
|
import { UploadFileItem } from '@/types/files/upload';
|
20
|
+
import { isChunkingUnsupported } from '@/utils/isChunkingUnsupported';
|
20
21
|
import { sleep } from '@/utils/sleep';
|
21
22
|
import { setNamespace } from '@/utils/storeDebug';
|
22
23
|
|
@@ -151,7 +152,7 @@ export const createFileSlice: StateCreator<
|
|
151
152
|
if (!fileResult) return;
|
152
153
|
|
153
154
|
// image don't need to be chunked and embedding
|
154
|
-
if (file.type
|
155
|
+
if (isChunkingUnsupported(file.type)) return;
|
155
156
|
|
156
157
|
// 3. auto chunk and embedding
|
157
158
|
dispatchChatUploadFileList({
|
@@ -0,0 +1,43 @@
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
2
|
+
|
3
|
+
import { isChunkingUnsupported } from './isChunkingUnsupported';
|
4
|
+
|
5
|
+
describe('isChunkingUnsupported', () => {
|
6
|
+
it('should return true for image file types', () => {
|
7
|
+
expect(isChunkingUnsupported('image/jpeg')).toBe(true);
|
8
|
+
expect(isChunkingUnsupported('image/png')).toBe(true);
|
9
|
+
expect(isChunkingUnsupported('image/gif')).toBe(true);
|
10
|
+
expect(isChunkingUnsupported('image/svg+xml')).toBe(true);
|
11
|
+
});
|
12
|
+
|
13
|
+
it('should return true for video file types', () => {
|
14
|
+
expect(isChunkingUnsupported('video/mp4')).toBe(true);
|
15
|
+
expect(isChunkingUnsupported('video/quicktime')).toBe(true);
|
16
|
+
expect(isChunkingUnsupported('video/x-msvideo')).toBe(true);
|
17
|
+
expect(isChunkingUnsupported('video/webm')).toBe(true);
|
18
|
+
});
|
19
|
+
|
20
|
+
it('should return true for audio file types', () => {
|
21
|
+
expect(isChunkingUnsupported('audio/mpeg')).toBe(true);
|
22
|
+
expect(isChunkingUnsupported('audio/wav')).toBe(true);
|
23
|
+
expect(isChunkingUnsupported('audio/ogg')).toBe(true);
|
24
|
+
expect(isChunkingUnsupported('audio/midi')).toBe(true);
|
25
|
+
});
|
26
|
+
|
27
|
+
it('should return false for other file types', () => {
|
28
|
+
expect(isChunkingUnsupported('text/plain')).toBe(false);
|
29
|
+
expect(isChunkingUnsupported('application/pdf')).toBe(false);
|
30
|
+
expect(isChunkingUnsupported('application/json')).toBe(false);
|
31
|
+
expect(isChunkingUnsupported('application/xml')).toBe(false);
|
32
|
+
});
|
33
|
+
|
34
|
+
it('should handle empty string input', () => {
|
35
|
+
expect(isChunkingUnsupported('')).toBe(false);
|
36
|
+
});
|
37
|
+
|
38
|
+
it('should handle non-standard file types', () => {
|
39
|
+
expect(isChunkingUnsupported('image-x-custom')).toBe(true);
|
40
|
+
expect(isChunkingUnsupported('video-custom')).toBe(true);
|
41
|
+
expect(isChunkingUnsupported('audio-special')).toBe(true);
|
42
|
+
});
|
43
|
+
});
|
@@ -0,0 +1,6 @@
|
|
1
|
+
export const isChunkingUnsupported = (fileType: string): boolean => {
|
2
|
+
if (fileType.startsWith('image')) return true;
|
3
|
+
if (fileType.startsWith('video')) return true;
|
4
|
+
if (fileType.startsWith('audio')) return true;
|
5
|
+
return false; // false doesn't mean supported, it means we don't know
|
6
|
+
};
|