Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

Fix: Files being parsed are not allowed to be deleted in batches #7065 (#7066)

balibabude5727f90a7e
diff --git a/web/src/locales/en.ts b/web/src/locales/en.ts
index 836cfb6931..432531459d 100644
--- a/web/src/locales/en.ts
+++ b/web/src/locales/en.ts
@@ -379,6 +379,8 @@ This auto-tagging feature enhances retrieval by adding another layer of domain-s
community: 'Community reports generation',
communityTip:
'In a knowledge graph, a community is a cluster of entities linked by relationships. You can have the LLM generate an abstract for each community, known as a community report. See here for more information: https://www.microsoft.com/en-us/research/blog/graphrag-improving-global-search-via-dynamic-community-selection/',
+ theDocumentBeingParsedCannotBeDeleted:
+ 'The document being parsed cannot be deleted',
},
chunk: {
chunk: 'Chunk',
diff --git a/web/src/locales/zh-traditional.ts b/web/src/locales/zh-traditional.ts
index 6e7bfd08ad..5aaa2819fd 100644
--- a/web/src/locales/zh-traditional.ts
+++ b/web/src/locales/zh-traditional.ts
@@ -196,6 +196,7 @@ export default {
'該文件與知識圖譜相關聯。刪除後,相關節點和關係資訊將被刪除,但圖不會立即更新。更新圖動作是在解析承載知識圖譜提取任務的新文件的過程中執行的。 ',
plainText: 'Naive',
reRankModelWaring: '重排序模型非常耗時。',
+ theDocumentBeingParsedCannotBeDeleted: '正在解析的文檔不能被刪除',
},
knowledgeConfiguration: {
titleDescription: '在這裡更新您的知識庫詳細信息,尤其是切片方法。',
diff --git a/web/src/locales/zh.ts b/web/src/locales/zh.ts
index e707e7b6a0..f395dfe1c1 100644
--- a/web/src/locales/zh.ts
+++ b/web/src/locales/zh.ts
@@ -196,6 +196,7 @@ export default {
'该文档与知识图谱相关联。删除后,相关节点和关系信息将被删除,但图不会立即更新。更新图动作是在解析承载知识图谱提取任务的新文档的过程中执行的。',
plainText: 'Naive',
reRankModelWaring: '重排序模型非常耗时。',
+ theDocumentBeingParsedCannotBeDeleted: '正在解析的文档不能被删除',
},
knowledgeConfiguration: {
titleDescription: '在这里更新您的知识库详细信息,尤其是切片方法。',
diff --git a/web/src/pages/add-knowledge/components/knowledge-file/document-toolbar.tsx b/web/src/pages/add-knowledge/components/knowledge-file/document-toolbar.tsx
index 0b003f1033..f55b0d6f19 100644
--- a/web/src/pages/add-knowledge/components/knowledge-file/document-toolbar.tsx
+++ b/web/src/pages/add-knowledge/components/knowledge-file/document-toolbar.tsx
@@ -9,6 +9,7 @@ import {
useRunNextDocument,
useSetNextDocumentStatus,
} from '@/hooks/document-hooks';
+import { IDocumentInfo } from '@/interfaces/database/document';
import {
DownOutlined,
FileOutlined,
@@ -18,6 +19,8 @@ import {
} from '@ant-design/icons';
import { Button, Dropdown, Flex, Input, MenuProps, Space } from 'antd';
import { useCallback, useMemo } from 'react';
+import { toast } from 'sonner';
+import { RunningStatus } from './constant';
import styles from './index.less';
@@ -28,6 +31,7 @@ interface IProps {
showDocumentUploadModal(): void;
searchString: string;
handleInputChange: React.ChangeEventHandler<HTMLInputElement>;
+ documents: IDocumentInfo[];
}
const DocumentToolbar = ({
@@ -36,6 +40,7 @@ const DocumentToolbar = ({
showCreateModal,
showDocumentUploadModal,
handleInputChange,
+ documents,
}: IProps) => {
const { t } = useTranslate('knowledgeDetails');
const { removeDocument } = useRemoveNextDocument();
@@ -76,18 +81,29 @@ const DocumentToolbar = ({
}, [showDocumentUploadModal, showCreateModal, t]);
const handleDelete = useCallback(() => {
+ const deletedKeys = selectedRowKeys.filter(
+ (x) =>
+ !documents
+ .filter((y) => y.run === RunningStatus.RUNNING)
+ .some((y) => y.id === x),
+ );
+ if (deletedKeys.length === 0) {
+ toast.error(t('theDocumentBeingParsedCannotBeDeleted'));
+ return;
+ }
showDeleteConfirm({
onOk: () => {
- removeDocument(selectedRowKeys);
+ removeDocument(deletedKeys);
},
});
- }, [removeDocument, showDeleteConfirm, selectedRowKeys]);
+ }, [selectedRowKeys, showDeleteConfirm, documents, t, removeDocument]);
const runDocument = useCallback(
(run: number) => {
runDocumentByIds({
documentIds: selectedRowKeys,
run,
+ shouldDelete: false,
});
},
[runDocumentByIds, selectedRowKeys],
diff --git a/web/src/pages/add-knowledge/components/knowledge-file/hooks.ts b/web/src/pages/add-knowledge/components/knowledge-file/hooks.ts
index 1105e1c787..005a72e433 100644
--- a/web/src/pages/add-knowledge/components/knowledge-file/hooks.ts
+++ b/web/src/pages/add-knowledge/components/knowledge-file/hooks.ts
@@ -9,8 +9,10 @@ import {
useUploadNextDocument,
} from '@/hooks/document-hooks';
import { useGetKnowledgeSearchParams } from '@/hooks/route-hook';
+import { IDocumentInfo } from '@/interfaces/database/document';
import { IChangeParserConfigRequestBody } from '@/interfaces/request/document';
import { UploadFile } from 'antd';
+import { TableRowSelection } from 'antd/es/table/interface';
import { useCallback, useState } from 'react';
import { useNavigate } from 'umi';
import { KnowledgeRouteKey } from './constant';
@@ -126,7 +128,7 @@ export const useChangeDocumentParser = (documentId: string) => {
export const useGetRowSelection = () => {
const [selectedRowKeys, setSelectedRowKeys] = useState<React.Key[]>([]);
- const rowSelection = {
+ const rowSelection: TableRowSelection<IDocumentInfo> = {
selectedRowKeys,
onChange: (newSelectedRowKeys: React.Key[]) => {
setSelectedRowKeys(newSelectedRowKeys);
diff --git a/web/src/pages/add-knowledge/components/knowledge-file/index.tsx b/web/src/pages/add-knowledge/components/knowledge-file/index.tsx
index 1ce7df8cc3..83119563bf 100644
--- a/web/src/pages/add-knowledge/components/knowledge-file/index.tsx
+++ b/web/src/pages/add-knowledge/components/knowledge-file/index.tsx
@@ -195,6 +195,7 @@ const KnowledgeFile = () => {
showDocumentUploadModal={showDocumentUploadModal}
searchString={searchString}
handleInputChange={handleInputChange}
+ documents={documents}
></DocumentToolbar>
<Table
rowKey="id"