瀏覽代碼

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

### What problem does this PR solve?

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

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
tags/v0.18.0
balibabu 6 月之前
父節點
當前提交
de5727f90a
沒有連結到貢獻者的電子郵件帳戶。

+ 2
- 0
web/src/locales/en.ts 查看文件

community: 'Community reports generation', community: 'Community reports generation',
communityTip: 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/', '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: 'Chunk', chunk: 'Chunk',

+ 1
- 0
web/src/locales/zh-traditional.ts 查看文件

'該文件與知識圖譜相關聯。刪除後,相關節點和關係資訊將被刪除,但圖不會立即更新。更新圖動作是在解析承載知識圖譜提取任務的新文件的過程中執行的。 ', '該文件與知識圖譜相關聯。刪除後,相關節點和關係資訊將被刪除,但圖不會立即更新。更新圖動作是在解析承載知識圖譜提取任務的新文件的過程中執行的。 ',
plainText: 'Naive', plainText: 'Naive',
reRankModelWaring: '重排序模型非常耗時。', reRankModelWaring: '重排序模型非常耗時。',
theDocumentBeingParsedCannotBeDeleted: '正在解析的文檔不能被刪除',
}, },
knowledgeConfiguration: { knowledgeConfiguration: {
titleDescription: '在這裡更新您的知識庫詳細信息,尤其是切片方法。', titleDescription: '在這裡更新您的知識庫詳細信息,尤其是切片方法。',

+ 1
- 0
web/src/locales/zh.ts 查看文件

'该文档与知识图谱相关联。删除后,相关节点和关系信息将被删除,但图不会立即更新。更新图动作是在解析承载知识图谱提取任务的新文档的过程中执行的。', '该文档与知识图谱相关联。删除后,相关节点和关系信息将被删除,但图不会立即更新。更新图动作是在解析承载知识图谱提取任务的新文档的过程中执行的。',
plainText: 'Naive', plainText: 'Naive',
reRankModelWaring: '重排序模型非常耗时。', reRankModelWaring: '重排序模型非常耗时。',
theDocumentBeingParsedCannotBeDeleted: '正在解析的文档不能被删除',
}, },
knowledgeConfiguration: { knowledgeConfiguration: {
titleDescription: '在这里更新您的知识库详细信息,尤其是切片方法。', titleDescription: '在这里更新您的知识库详细信息,尤其是切片方法。',

+ 18
- 2
web/src/pages/add-knowledge/components/knowledge-file/document-toolbar.tsx 查看文件

useRunNextDocument, useRunNextDocument,
useSetNextDocumentStatus, useSetNextDocumentStatus,
} from '@/hooks/document-hooks'; } from '@/hooks/document-hooks';
import { IDocumentInfo } from '@/interfaces/database/document';
import { import {
DownOutlined, DownOutlined,
FileOutlined, FileOutlined,
} from '@ant-design/icons'; } from '@ant-design/icons';
import { Button, Dropdown, Flex, Input, MenuProps, Space } from 'antd'; import { Button, Dropdown, Flex, Input, MenuProps, Space } from 'antd';
import { useCallback, useMemo } from 'react'; import { useCallback, useMemo } from 'react';
import { toast } from 'sonner';
import { RunningStatus } from './constant';


import styles from './index.less'; import styles from './index.less';


showDocumentUploadModal(): void; showDocumentUploadModal(): void;
searchString: string; searchString: string;
handleInputChange: React.ChangeEventHandler<HTMLInputElement>; handleInputChange: React.ChangeEventHandler<HTMLInputElement>;
documents: IDocumentInfo[];
} }


const DocumentToolbar = ({ const DocumentToolbar = ({
showCreateModal, showCreateModal,
showDocumentUploadModal, showDocumentUploadModal,
handleInputChange, handleInputChange,
documents,
}: IProps) => { }: IProps) => {
const { t } = useTranslate('knowledgeDetails'); const { t } = useTranslate('knowledgeDetails');
const { removeDocument } = useRemoveNextDocument(); const { removeDocument } = useRemoveNextDocument();
}, [showDocumentUploadModal, showCreateModal, t]); }, [showDocumentUploadModal, showCreateModal, t]);


const handleDelete = useCallback(() => { 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({ showDeleteConfirm({
onOk: () => { onOk: () => {
removeDocument(selectedRowKeys);
removeDocument(deletedKeys);
}, },
}); });
}, [removeDocument, showDeleteConfirm, selectedRowKeys]);
}, [selectedRowKeys, showDeleteConfirm, documents, t, removeDocument]);


const runDocument = useCallback( const runDocument = useCallback(
(run: number) => { (run: number) => {
runDocumentByIds({ runDocumentByIds({
documentIds: selectedRowKeys, documentIds: selectedRowKeys,
run, run,
shouldDelete: false,
}); });
}, },
[runDocumentByIds, selectedRowKeys], [runDocumentByIds, selectedRowKeys],

+ 3
- 1
web/src/pages/add-knowledge/components/knowledge-file/hooks.ts 查看文件

useUploadNextDocument, useUploadNextDocument,
} from '@/hooks/document-hooks'; } from '@/hooks/document-hooks';
import { useGetKnowledgeSearchParams } from '@/hooks/route-hook'; import { useGetKnowledgeSearchParams } from '@/hooks/route-hook';
import { IDocumentInfo } from '@/interfaces/database/document';
import { IChangeParserConfigRequestBody } from '@/interfaces/request/document'; import { IChangeParserConfigRequestBody } from '@/interfaces/request/document';
import { UploadFile } from 'antd'; import { UploadFile } from 'antd';
import { TableRowSelection } from 'antd/es/table/interface';
import { useCallback, useState } from 'react'; import { useCallback, useState } from 'react';
import { useNavigate } from 'umi'; import { useNavigate } from 'umi';
import { KnowledgeRouteKey } from './constant'; import { KnowledgeRouteKey } from './constant';
export const useGetRowSelection = () => { export const useGetRowSelection = () => {
const [selectedRowKeys, setSelectedRowKeys] = useState<React.Key[]>([]); const [selectedRowKeys, setSelectedRowKeys] = useState<React.Key[]>([]);


const rowSelection = {
const rowSelection: TableRowSelection<IDocumentInfo> = {
selectedRowKeys, selectedRowKeys,
onChange: (newSelectedRowKeys: React.Key[]) => { onChange: (newSelectedRowKeys: React.Key[]) => {
setSelectedRowKeys(newSelectedRowKeys); setSelectedRowKeys(newSelectedRowKeys);

+ 1
- 0
web/src/pages/add-knowledge/components/knowledge-file/index.tsx 查看文件

showDocumentUploadModal={showDocumentUploadModal} showDocumentUploadModal={showDocumentUploadModal}
searchString={searchString} searchString={searchString}
handleInputChange={handleInputChange} handleInputChange={handleInputChange}
documents={documents}
></DocumentToolbar> ></DocumentToolbar>
<Table <Table
rowKey="id" rowKey="id"

Loading…
取消
儲存