mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-30 08:35:33 +08:00
Fix: Memory-related bug fixes (#12226)
### What problem does this PR solve? Fix: bugs fix - table -> Table - memory delete fail - memory copywriting modified ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
@ -266,20 +266,19 @@ export const useRunDocument = () => {
|
|||||||
mutationFn: async ({
|
mutationFn: async ({
|
||||||
documentIds,
|
documentIds,
|
||||||
run,
|
run,
|
||||||
shouldDelete,
|
option,
|
||||||
}: {
|
}: {
|
||||||
documentIds: string[];
|
documentIds: string[];
|
||||||
run: number;
|
run: number;
|
||||||
shouldDelete: boolean;
|
option?: { delete: boolean; apply_kb: boolean };
|
||||||
}) => {
|
}) => {
|
||||||
queryClient.invalidateQueries({
|
queryClient.invalidateQueries({
|
||||||
queryKey: [DocumentApiAction.FetchDocumentList],
|
queryKey: [DocumentApiAction.FetchDocumentList],
|
||||||
});
|
});
|
||||||
|
|
||||||
const ret = await kbService.document_run({
|
const ret = await kbService.document_run({
|
||||||
doc_ids: documentIds,
|
doc_ids: documentIds,
|
||||||
run,
|
run,
|
||||||
delete: shouldDelete,
|
...option,
|
||||||
});
|
});
|
||||||
const code = get(ret, 'data.code');
|
const code = get(ret, 'data.code');
|
||||||
if (code === 0) {
|
if (code === 0) {
|
||||||
|
|||||||
@ -125,8 +125,9 @@ Procedural Memory: Learned skills, habits, and automated procedures.`,
|
|||||||
},
|
},
|
||||||
memory: {
|
memory: {
|
||||||
messages: {
|
messages: {
|
||||||
|
forgetMessageTip: 'Are you sure you want to forget?',
|
||||||
messageDescription:
|
messageDescription:
|
||||||
'Memory retrieval is configured with Similarity threshold, Keyword similarity weight, and Top N from Advanced Settings.',
|
'Memory extract is configured with Prompts and Temperature from Advanced Settings.',
|
||||||
copied: 'Copied!',
|
copied: 'Copied!',
|
||||||
contentEmbed: 'Content embed',
|
contentEmbed: 'Content embed',
|
||||||
content: 'Content',
|
content: 'Content',
|
||||||
@ -216,6 +217,10 @@ Procedural Memory: Learned skills, habits, and automated procedures.`,
|
|||||||
deleteSettingFieldWarn: `This field will be deleted; existing metadata won't be affected.`,
|
deleteSettingFieldWarn: `This field will be deleted; existing metadata won't be affected.`,
|
||||||
deleteSettingValueWarn: `This value will be deleted; existing metadata won't be affected.`,
|
deleteSettingValueWarn: `This value will be deleted; existing metadata won't be affected.`,
|
||||||
},
|
},
|
||||||
|
redoAll: 'Clear existing chunks',
|
||||||
|
applyAutoMetadataSettings: 'Apply global auto-metadata settings',
|
||||||
|
parseFileTip: 'Are you sure to parse?',
|
||||||
|
parseFile: 'Parse file',
|
||||||
emptyMetadata: 'No metadata',
|
emptyMetadata: 'No metadata',
|
||||||
metadataField: 'Metadata field',
|
metadataField: 'Metadata field',
|
||||||
systemAttribute: 'System attribute',
|
systemAttribute: 'System attribute',
|
||||||
@ -455,7 +460,7 @@ Procedural Memory: Learned skills, habits, and automated procedures.`,
|
|||||||
manualSetup: 'Choose pipeline',
|
manualSetup: 'Choose pipeline',
|
||||||
builtIn: 'Built-in',
|
builtIn: 'Built-in',
|
||||||
titleDescription:
|
titleDescription:
|
||||||
'Update your knowledge base configuration here, particularly the chunking method.',
|
'Update your memory configuration here, particularly the LLM and prompts.',
|
||||||
name: 'Knowledge base name',
|
name: 'Knowledge base name',
|
||||||
photo: 'Knowledge base photo',
|
photo: 'Knowledge base photo',
|
||||||
photoTip: 'You can upload a file with 4 MB',
|
photoTip: 'You can upload a file with 4 MB',
|
||||||
|
|||||||
@ -117,8 +117,8 @@ export default {
|
|||||||
},
|
},
|
||||||
memory: {
|
memory: {
|
||||||
messages: {
|
messages: {
|
||||||
messageDescription:
|
forgetMessageTip: '确定遗忘吗?',
|
||||||
'记忆检索已在高级设置中配置相似度阈值、关键词相似度权重和前N个结果。',
|
messageDescription: '记忆提取使用高级设置中的提示词和温度值进行配置。',
|
||||||
copied: '已复制!',
|
copied: '已复制!',
|
||||||
contentEmbed: '内容嵌入',
|
contentEmbed: '内容嵌入',
|
||||||
content: '内容',
|
content: '内容',
|
||||||
@ -201,6 +201,10 @@ export default {
|
|||||||
deleteSettingFieldWarn: `此字段将被删除;现有元数据不会受到影响。`,
|
deleteSettingFieldWarn: `此字段将被删除;现有元数据不会受到影响。`,
|
||||||
deleteSettingValueWarn: `此值将被删除;现有元数据不会受到影响。`,
|
deleteSettingValueWarn: `此值将被删除;现有元数据不会受到影响。`,
|
||||||
},
|
},
|
||||||
|
redoAll: '清除现有分块',
|
||||||
|
applyAutoMetadataSettings: '应用全局自动元数据设置',
|
||||||
|
parseFileTip: '您确定要解析吗?',
|
||||||
|
parseFile: '解析文件',
|
||||||
emptyMetadata: '无元数据',
|
emptyMetadata: '无元数据',
|
||||||
localUpload: '本地上传',
|
localUpload: '本地上传',
|
||||||
fileSize: '文件大小',
|
fileSize: '文件大小',
|
||||||
@ -418,7 +422,7 @@ export default {
|
|||||||
parseType: '解析方法',
|
parseType: '解析方法',
|
||||||
manualSetup: '选择pipeline',
|
manualSetup: '选择pipeline',
|
||||||
builtIn: '内置',
|
builtIn: '内置',
|
||||||
titleDescription: '在这里更新您的知识库详细信息,尤其是切片方法。',
|
titleDescription: '在这里更新您的记忆配置,特别是大语言模型和提示词。',
|
||||||
name: '知识库名称',
|
name: '知识库名称',
|
||||||
photo: '知识库图片',
|
photo: '知识库图片',
|
||||||
photoTip: '你可以上传4MB的文件',
|
photoTip: '你可以上传4MB的文件',
|
||||||
|
|||||||
@ -23,6 +23,7 @@ import {
|
|||||||
import { ManageMetadataModal } from '../components/metedata/manage-modal';
|
import { ManageMetadataModal } from '../components/metedata/manage-modal';
|
||||||
import { DatasetTable } from './dataset-table';
|
import { DatasetTable } from './dataset-table';
|
||||||
import Generate from './generate-button/generate';
|
import Generate from './generate-button/generate';
|
||||||
|
import { ReparseDialog } from './reparse-dialog';
|
||||||
import { useBulkOperateDataset } from './use-bulk-operate-dataset';
|
import { useBulkOperateDataset } from './use-bulk-operate-dataset';
|
||||||
import { useCreateEmptyDocument } from './use-create-empty-document';
|
import { useCreateEmptyDocument } from './use-create-empty-document';
|
||||||
import { useSelectDatasetFilters } from './use-select-filters';
|
import { useSelectDatasetFilters } from './use-select-filters';
|
||||||
@ -77,7 +78,12 @@ export default function Dataset() {
|
|||||||
const { rowSelection, rowSelectionIsEmpty, setRowSelection, selectedCount } =
|
const { rowSelection, rowSelectionIsEmpty, setRowSelection, selectedCount } =
|
||||||
useRowSelection();
|
useRowSelection();
|
||||||
|
|
||||||
const { list } = useBulkOperateDataset({
|
const {
|
||||||
|
list,
|
||||||
|
visible: reparseDialogVisible,
|
||||||
|
hideModal: hideReparseDialogModal,
|
||||||
|
handleRunClick: handleOperationIconClick,
|
||||||
|
} = useBulkOperateDataset({
|
||||||
documents,
|
documents,
|
||||||
rowSelection,
|
rowSelection,
|
||||||
setRowSelection,
|
setRowSelection,
|
||||||
@ -207,6 +213,16 @@ export default function Dataset() {
|
|||||||
otherData={metadataConfig.record}
|
otherData={metadataConfig.record}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
{reparseDialogVisible && (
|
||||||
|
<ReparseDialog
|
||||||
|
// hidden={isZeroChunk || isRunning}
|
||||||
|
hidden={false}
|
||||||
|
handleOperationIconClick={handleOperationIconClick}
|
||||||
|
chunk_num={0}
|
||||||
|
visible={reparseDialogVisible}
|
||||||
|
hideModal={hideReparseDialogModal}
|
||||||
|
></ReparseDialog>
|
||||||
|
)}
|
||||||
</section>
|
</section>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
import { ConfirmDeleteDialog } from '@/components/confirm-delete-dialog';
|
|
||||||
import { IconFontFill } from '@/components/icon-font';
|
import { IconFontFill } from '@/components/icon-font';
|
||||||
import {
|
import {
|
||||||
DropdownMenu,
|
DropdownMenu,
|
||||||
@ -19,6 +18,7 @@ import { useCallback, useMemo } from 'react';
|
|||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { DocumentType, RunningStatus } from './constant';
|
import { DocumentType, RunningStatus } from './constant';
|
||||||
import { ParsingCard } from './parsing-card';
|
import { ParsingCard } from './parsing-card';
|
||||||
|
import { ReparseDialog } from './reparse-dialog';
|
||||||
import { UseChangeDocumentParserShowType } from './use-change-document-parser';
|
import { UseChangeDocumentParserShowType } from './use-change-document-parser';
|
||||||
import { useHandleRunDocumentByIds } from './use-run-document';
|
import { useHandleRunDocumentByIds } from './use-run-document';
|
||||||
import { UseSaveMetaShowType } from './use-save-meta';
|
import { UseSaveMetaShowType } from './use-save-meta';
|
||||||
@ -63,15 +63,21 @@ export function ParsingStatusCell({
|
|||||||
} = record;
|
} = record;
|
||||||
const operationIcon = IconMap[run];
|
const operationIcon = IconMap[run];
|
||||||
const p = Number((progress * 100).toFixed(2));
|
const p = Number((progress * 100).toFixed(2));
|
||||||
const { handleRunDocumentByIds } = useHandleRunDocumentByIds(id);
|
const {
|
||||||
|
handleRunDocumentByIds,
|
||||||
|
visible: reparseDialogVisible,
|
||||||
|
showModal: showReparseDialogModal,
|
||||||
|
hideModal: hideReparseDialogModal,
|
||||||
|
} = useHandleRunDocumentByIds(id);
|
||||||
const isRunning = isParserRunning(run);
|
const isRunning = isParserRunning(run);
|
||||||
const isZeroChunk = chunk_num === 0;
|
const isZeroChunk = chunk_num === 0;
|
||||||
|
|
||||||
const handleOperationIconClick =
|
const handleOperationIconClick = (option: {
|
||||||
(shouldDelete: boolean = false) =>
|
delete: boolean;
|
||||||
() => {
|
apply_kb: boolean;
|
||||||
handleRunDocumentByIds(record.id, isRunning, shouldDelete);
|
}) => {
|
||||||
};
|
handleRunDocumentByIds(record.id, isRunning, option);
|
||||||
|
};
|
||||||
|
|
||||||
const handleShowChangeParserModal = useCallback(() => {
|
const handleShowChangeParserModal = useCallback(() => {
|
||||||
showChangeParserModal(record);
|
showChangeParserModal(record);
|
||||||
@ -129,23 +135,20 @@ export function ParsingStatusCell({
|
|||||||
<div className="flex items-center gap-3">
|
<div className="flex items-center gap-3">
|
||||||
<Separator orientation="vertical" className="h-2.5" />
|
<Separator orientation="vertical" className="h-2.5" />
|
||||||
{!isParserRunning(run) && (
|
{!isParserRunning(run) && (
|
||||||
<ConfirmDeleteDialog
|
// <ReparseDialog
|
||||||
title={t(`knowledgeDetails.redo`, { chunkNum: chunk_num })}
|
// hidden={isZeroChunk || isRunning}
|
||||||
hidden={isZeroChunk || isRunning}
|
// handleOperationIconClick={handleOperationIconClick}
|
||||||
onOk={handleOperationIconClick(true)}
|
// chunk_num={chunk_num}
|
||||||
onCancel={handleOperationIconClick(false)}
|
// >
|
||||||
|
<div
|
||||||
|
className="cursor-pointer flex items-center gap-3"
|
||||||
|
onClick={() => {
|
||||||
|
showReparseDialogModal();
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<div
|
{!isParserRunning(run) && operationIcon}
|
||||||
className="cursor-pointer flex items-center gap-3"
|
</div>
|
||||||
onClick={
|
// {/* </ReparseDialog> */}
|
||||||
isZeroChunk || isRunning
|
|
||||||
? handleOperationIconClick(false)
|
|
||||||
: () => {}
|
|
||||||
}
|
|
||||||
>
|
|
||||||
{!isParserRunning(run) && operationIcon}
|
|
||||||
</div>
|
|
||||||
</ConfirmDeleteDialog>
|
|
||||||
)}
|
)}
|
||||||
{isParserRunning(run) ? (
|
{isParserRunning(run) ? (
|
||||||
<>
|
<>
|
||||||
@ -158,11 +161,14 @@ export function ParsingStatusCell({
|
|||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
className="cursor-pointer flex items-center gap-3"
|
className="cursor-pointer flex items-center gap-3"
|
||||||
onClick={
|
onClick={() => {
|
||||||
isZeroChunk || isRunning
|
showReparseDialogModal();
|
||||||
? handleOperationIconClick(false)
|
}}
|
||||||
: () => {}
|
// onClick={
|
||||||
}
|
// isZeroChunk || isRunning
|
||||||
|
// ? handleOperationIconClick(false)
|
||||||
|
// : () => {}
|
||||||
|
// }
|
||||||
>
|
>
|
||||||
{operationIcon}
|
{operationIcon}
|
||||||
</div>
|
</div>
|
||||||
@ -175,6 +181,16 @@ export function ParsingStatusCell({
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
{reparseDialogVisible && (
|
||||||
|
<ReparseDialog
|
||||||
|
// hidden={isZeroChunk || isRunning}
|
||||||
|
hidden={false}
|
||||||
|
handleOperationIconClick={handleOperationIconClick}
|
||||||
|
chunk_num={chunk_num}
|
||||||
|
visible={reparseDialogVisible}
|
||||||
|
hideModal={hideReparseDialogModal}
|
||||||
|
></ReparseDialog>
|
||||||
|
)}
|
||||||
</section>
|
</section>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
154
web/src/pages/dataset/dataset/reparse-dialog.tsx
Normal file
154
web/src/pages/dataset/dataset/reparse-dialog.tsx
Normal file
@ -0,0 +1,154 @@
|
|||||||
|
import { ConfirmDeleteDialog } from '@/components/confirm-delete-dialog';
|
||||||
|
import {
|
||||||
|
DynamicForm,
|
||||||
|
DynamicFormRef,
|
||||||
|
FormFieldType,
|
||||||
|
} from '@/components/dynamic-form';
|
||||||
|
import { Checkbox } from '@/components/ui/checkbox';
|
||||||
|
import { DialogProps } from '@radix-ui/react-dialog';
|
||||||
|
import { t } from 'i18next';
|
||||||
|
import { useCallback, useState } from 'react';
|
||||||
|
|
||||||
|
export const ReparseDialog = ({
|
||||||
|
handleOperationIconClick,
|
||||||
|
chunk_num,
|
||||||
|
hidden = false,
|
||||||
|
visible = true,
|
||||||
|
hideModal,
|
||||||
|
children,
|
||||||
|
}: DialogProps & {
|
||||||
|
chunk_num: number;
|
||||||
|
handleOperationIconClick: (options: {
|
||||||
|
delete: boolean;
|
||||||
|
apply_kb: boolean;
|
||||||
|
}) => void;
|
||||||
|
visible: boolean;
|
||||||
|
hideModal: () => void;
|
||||||
|
hidden?: boolean;
|
||||||
|
}) => {
|
||||||
|
const [formInstance, setFormInstance] = useState<DynamicFormRef | null>(null);
|
||||||
|
|
||||||
|
const formCallbackRef = useCallback((node: DynamicFormRef | null) => {
|
||||||
|
if (node) {
|
||||||
|
setFormInstance(node);
|
||||||
|
console.log('Form instance assigned:', node);
|
||||||
|
} else {
|
||||||
|
console.log('Form instance removed');
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const handleCancel = useCallback(() => {
|
||||||
|
// handleOperationIconClick(false);
|
||||||
|
hideModal?.();
|
||||||
|
formInstance?.reset();
|
||||||
|
}, [formInstance]);
|
||||||
|
|
||||||
|
const handleSave = useCallback(async () => {
|
||||||
|
const instance = formInstance;
|
||||||
|
if (!instance) {
|
||||||
|
console.error('Form instance is null');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const check = await instance.trigger();
|
||||||
|
if (check) {
|
||||||
|
instance.submit();
|
||||||
|
const formValues = instance.getValues();
|
||||||
|
console.log(formValues);
|
||||||
|
handleOperationIconClick({
|
||||||
|
delete: formValues.delete,
|
||||||
|
apply_kb: formValues.apply_kb,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, [formInstance, handleOperationIconClick]);
|
||||||
|
|
||||||
|
// useEffect(() => {
|
||||||
|
// if (!hidden) {
|
||||||
|
// const timer = setTimeout(() => {
|
||||||
|
// if (!formInstance) {
|
||||||
|
// console.warn(
|
||||||
|
// 'Form ref is still null after component should be mounted',
|
||||||
|
// );
|
||||||
|
// } else {
|
||||||
|
// console.log('Form ref is properly set');
|
||||||
|
// }
|
||||||
|
// }, 1000);
|
||||||
|
|
||||||
|
// return () => clearTimeout(timer);
|
||||||
|
// }
|
||||||
|
// }, [hidden, formInstance]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ConfirmDeleteDialog
|
||||||
|
title={t(`knowledgeDetails.parseFile`)}
|
||||||
|
onOk={() => handleSave()}
|
||||||
|
onCancel={() => handleCancel()}
|
||||||
|
hidden={hidden}
|
||||||
|
open={visible}
|
||||||
|
content={{
|
||||||
|
title: t(`knowledgeDetails.parseFileTip`),
|
||||||
|
node: (
|
||||||
|
<div>
|
||||||
|
<DynamicForm.Root
|
||||||
|
onSubmit={(data) => {
|
||||||
|
console.log('submit', data);
|
||||||
|
}}
|
||||||
|
ref={formCallbackRef}
|
||||||
|
fields={[
|
||||||
|
{
|
||||||
|
name: 'delete',
|
||||||
|
label: '',
|
||||||
|
type: FormFieldType.Checkbox,
|
||||||
|
render: (fieldProps) => (
|
||||||
|
<div className="flex items-center text-text-secondary p-5 border border-border-button rounded-lg">
|
||||||
|
<Checkbox
|
||||||
|
{...fieldProps}
|
||||||
|
onCheckedChange={(checked: boolean) => {
|
||||||
|
fieldProps.onChange(checked);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<span className="ml-2">
|
||||||
|
{chunk_num > 0
|
||||||
|
? t(`knowledgeDetails.redo`, { chunkNum: chunk_num })
|
||||||
|
: t('knowledgeDetails.redoAll')}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'apply_kb',
|
||||||
|
label: '',
|
||||||
|
type: FormFieldType.Checkbox,
|
||||||
|
render: (fieldProps) => (
|
||||||
|
<div className="flex items-center text-text-secondary p-5 border border-border-button rounded-lg">
|
||||||
|
<Checkbox
|
||||||
|
{...fieldProps}
|
||||||
|
onCheckedChange={(checked: boolean) => {
|
||||||
|
fieldProps.onChange(checked);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<span className="ml-2">
|
||||||
|
{t('knowledgeDetails.applyAutoMetadataSettings')}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
{/* <DynamicForm.CancelButton
|
||||||
|
handleCancel={() => handleOperationIconClick(false)}
|
||||||
|
cancelText={t('common.cancel')}
|
||||||
|
/>
|
||||||
|
<DynamicForm.SavingButton
|
||||||
|
buttonText={t('common.confirm')}
|
||||||
|
submitFunc={handleSave}
|
||||||
|
/> */}
|
||||||
|
</DynamicForm.Root>
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{/* {children} */}
|
||||||
|
</ConfirmDeleteDialog>
|
||||||
|
);
|
||||||
|
};
|
||||||
@ -1,3 +1,4 @@
|
|||||||
|
import { useSetModalState } from '@/hooks/common-hooks';
|
||||||
import {
|
import {
|
||||||
UseRowSelectionType,
|
UseRowSelectionType,
|
||||||
useSelectedIds,
|
useSelectedIds,
|
||||||
@ -30,9 +31,9 @@ export function useBulkOperateDataset({
|
|||||||
const { runDocumentByIds } = useRunDocument();
|
const { runDocumentByIds } = useRunDocument();
|
||||||
const { setDocumentStatus } = useSetDocumentStatus();
|
const { setDocumentStatus } = useSetDocumentStatus();
|
||||||
const { removeDocument } = useRemoveDocument();
|
const { removeDocument } = useRemoveDocument();
|
||||||
|
const { visible, showModal, hideModal } = useSetModalState();
|
||||||
const runDocument = useCallback(
|
const runDocument = useCallback(
|
||||||
(run: number) => {
|
async (run: number, option?: { delete: boolean; apply_kb: boolean }) => {
|
||||||
const nonVirtualKeys = selectedRowKeys.filter(
|
const nonVirtualKeys = selectedRowKeys.filter(
|
||||||
(x) =>
|
(x) =>
|
||||||
!documents.some((y) => x === y.id && y.type === DocumentType.Virtual),
|
!documents.some((y) => x === y.id && y.type === DocumentType.Virtual),
|
||||||
@ -42,18 +43,22 @@ export function useBulkOperateDataset({
|
|||||||
toast.error(t('Please select a non-empty file list'));
|
toast.error(t('Please select a non-empty file list'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
runDocumentByIds({
|
await runDocumentByIds({
|
||||||
documentIds: nonVirtualKeys,
|
documentIds: nonVirtualKeys,
|
||||||
run,
|
run,
|
||||||
shouldDelete: false,
|
option,
|
||||||
});
|
});
|
||||||
|
hideModal();
|
||||||
},
|
},
|
||||||
[documents, runDocumentByIds, selectedRowKeys, t],
|
[documents, runDocumentByIds, selectedRowKeys, hideModal, t],
|
||||||
);
|
);
|
||||||
|
|
||||||
const handleRunClick = useCallback(() => {
|
const handleRunClick = useCallback(
|
||||||
runDocument(1);
|
(option: { delete: boolean; apply_kb: boolean }) => {
|
||||||
}, [runDocument]);
|
runDocument(1, option);
|
||||||
|
},
|
||||||
|
[runDocument],
|
||||||
|
);
|
||||||
|
|
||||||
const handleCancelClick = useCallback(() => {
|
const handleCancelClick = useCallback(() => {
|
||||||
runDocument(2);
|
runDocument(2);
|
||||||
@ -106,7 +111,7 @@ export function useBulkOperateDataset({
|
|||||||
id: 'run',
|
id: 'run',
|
||||||
label: t('knowledgeDetails.run'),
|
label: t('knowledgeDetails.run'),
|
||||||
icon: <Play />,
|
icon: <Play />,
|
||||||
onClick: handleRunClick,
|
onClick: () => showModal(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'cancel',
|
id: 'cancel',
|
||||||
@ -127,5 +132,5 @@ export function useBulkOperateDataset({
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
return { list };
|
return { list, visible, hideModal, showModal, handleRunClick };
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
import { useSetModalState } from '@/hooks/common-hooks';
|
||||||
import { useRunDocument } from '@/hooks/use-document-request';
|
import { useRunDocument } from '@/hooks/use-document-request';
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
|
|
||||||
@ -5,11 +6,11 @@ export const useHandleRunDocumentByIds = (id: string) => {
|
|||||||
const { runDocumentByIds, loading } = useRunDocument();
|
const { runDocumentByIds, loading } = useRunDocument();
|
||||||
const [currentId, setCurrentId] = useState<string>('');
|
const [currentId, setCurrentId] = useState<string>('');
|
||||||
const isLoading = loading && currentId !== '' && currentId === id;
|
const isLoading = loading && currentId !== '' && currentId === id;
|
||||||
|
const { visible, showModal, hideModal } = useSetModalState();
|
||||||
const handleRunDocumentByIds = async (
|
const handleRunDocumentByIds = async (
|
||||||
documentId: string,
|
documentId: string,
|
||||||
isRunning: boolean,
|
isRunning: boolean,
|
||||||
shouldDelete: boolean = false,
|
option: { delete: boolean; apply_kb: boolean },
|
||||||
) => {
|
) => {
|
||||||
if (isLoading) {
|
if (isLoading) {
|
||||||
return;
|
return;
|
||||||
@ -19,16 +20,20 @@ export const useHandleRunDocumentByIds = (id: string) => {
|
|||||||
await runDocumentByIds({
|
await runDocumentByIds({
|
||||||
documentIds: [documentId],
|
documentIds: [documentId],
|
||||||
run: isRunning ? 2 : 1,
|
run: isRunning ? 2 : 1,
|
||||||
shouldDelete,
|
option,
|
||||||
});
|
});
|
||||||
setCurrentId('');
|
setCurrentId('');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setCurrentId('');
|
setCurrentId('');
|
||||||
}
|
}
|
||||||
|
hideModal();
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
handleRunDocumentByIds,
|
handleRunDocumentByIds,
|
||||||
loading: isLoading,
|
loading: isLoading,
|
||||||
|
visible,
|
||||||
|
showModal,
|
||||||
|
hideModal,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@ -39,7 +39,7 @@ export default function MemoryMessage() {
|
|||||||
messages={data?.messages?.message_list ?? []}
|
messages={data?.messages?.message_list ?? []}
|
||||||
pagination={pagination}
|
pagination={pagination}
|
||||||
setPagination={setPagination}
|
setPagination={setPagination}
|
||||||
total={data?.messages?.total ?? 0}
|
total={data?.messages?.total_count ?? 0}
|
||||||
// rowSelection={rowSelection}
|
// rowSelection={rowSelection}
|
||||||
// setRowSelection={setRowSelection}
|
// setRowSelection={setRowSelection}
|
||||||
// loading={loading}
|
// loading={loading}
|
||||||
|
|||||||
@ -14,7 +14,7 @@ export interface IMessageInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface IMessageTableProps {
|
export interface IMessageTableProps {
|
||||||
messages: { message_list: Array<IMessageInfo>; total: number };
|
messages: { message_list: Array<IMessageInfo>; total_count: number };
|
||||||
storage_type: string;
|
storage_type: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -252,6 +252,7 @@ export function MemoryTable({
|
|||||||
open={showDeleteDialog}
|
open={showDeleteDialog}
|
||||||
onOpenChange={setShowDeleteDialog}
|
onOpenChange={setShowDeleteDialog}
|
||||||
content={{
|
content={{
|
||||||
|
title: t('memory.messages.forgetMessageTip'),
|
||||||
node: (
|
node: (
|
||||||
<ConfirmDeleteDialogNode
|
<ConfirmDeleteDialogNode
|
||||||
// avatar={{ avatar: selectedMessage.avatar, name: selectedMessage.name }}
|
// avatar={{ avatar: selectedMessage.avatar, name: selectedMessage.name }}
|
||||||
|
|||||||
@ -80,8 +80,8 @@ export const AdvancedSettingsForm = () => {
|
|||||||
horizontal: true,
|
horizontal: true,
|
||||||
placeholder: t('memory.config.storageTypePlaceholder'),
|
placeholder: t('memory.config.storageTypePlaceholder'),
|
||||||
options: [
|
options: [
|
||||||
{ label: 'table', value: 'table' },
|
{ label: 'Table', value: 'table' },
|
||||||
// { label: 'graph', value: 'graph' },
|
// { label: 'Graph', value: 'graph' },
|
||||||
],
|
],
|
||||||
required: false,
|
required: false,
|
||||||
}}
|
}}
|
||||||
@ -95,7 +95,7 @@ export const AdvancedSettingsForm = () => {
|
|||||||
// placeholder: t('memory.config.storageTypePlaceholder'),
|
// placeholder: t('memory.config.storageTypePlaceholder'),
|
||||||
options: [
|
options: [
|
||||||
// { label: 'LRU', value: 'LRU' },
|
// { label: 'LRU', value: 'LRU' },
|
||||||
{ label: 'FIFO', value: 'FIFO' },
|
{ label: 'FIFO', value: 'fifo' },
|
||||||
],
|
],
|
||||||
required: false,
|
required: false,
|
||||||
}}
|
}}
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import { EmbeddingSelect } from '@/pages/dataset/dataset-setting/configuration/c
|
|||||||
import { MemoryType } from '@/pages/memories/constants';
|
import { MemoryType } from '@/pages/memories/constants';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
|
import { useFetchMemoryMessageList } from '../memory-message/hook';
|
||||||
|
|
||||||
export const memoryModelFormSchema = {
|
export const memoryModelFormSchema = {
|
||||||
embd_id: z.string(),
|
embd_id: z.string(),
|
||||||
@ -20,6 +21,7 @@ export const defaultMemoryModelForm = {
|
|||||||
export const MemoryModelForm = () => {
|
export const MemoryModelForm = () => {
|
||||||
const { modelOptions } = useModelOptions();
|
const { modelOptions } = useModelOptions();
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
const { data } = useFetchMemoryMessageList();
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<RenderField
|
<RenderField
|
||||||
@ -33,7 +35,11 @@ export const MemoryModelForm = () => {
|
|||||||
type: FormFieldType.Custom,
|
type: FormFieldType.Custom,
|
||||||
disabled: true,
|
disabled: true,
|
||||||
render: (field) => (
|
render: (field) => (
|
||||||
<EmbeddingSelect field={field} isEdit={false} disabled={true} />
|
<EmbeddingSelect
|
||||||
|
field={field}
|
||||||
|
isEdit={false}
|
||||||
|
disabled={data?.messages?.total_count > 0}
|
||||||
|
/>
|
||||||
),
|
),
|
||||||
|
|
||||||
tooltip: t('memories.embeddingModelTooltip'),
|
tooltip: t('memories.embeddingModelTooltip'),
|
||||||
@ -47,6 +53,7 @@ export const MemoryModelForm = () => {
|
|||||||
required: true,
|
required: true,
|
||||||
horizontal: true,
|
horizontal: true,
|
||||||
type: FormFieldType.Select,
|
type: FormFieldType.Select,
|
||||||
|
disabled: data?.messages?.total_count > 0,
|
||||||
options: modelOptions as { value: string; label: string }[],
|
options: modelOptions as { value: string; label: string }[],
|
||||||
tooltip: t('memories.llmTooltip'),
|
tooltip: t('memories.llmTooltip'),
|
||||||
}}
|
}}
|
||||||
|
|||||||
@ -239,7 +239,7 @@ export default {
|
|||||||
createMemory: `${api_host}/memories`,
|
createMemory: `${api_host}/memories`,
|
||||||
getMemoryList: `${api_host}/memories`,
|
getMemoryList: `${api_host}/memories`,
|
||||||
getMemoryConfig: (id: string) => `${api_host}/memories/${id}/config`,
|
getMemoryConfig: (id: string) => `${api_host}/memories/${id}/config`,
|
||||||
deleteMemory: (id: string) => `${api_host}/memory/rm/${id}`,
|
deleteMemory: (id: string) => `${api_host}/memories/${id}`,
|
||||||
getMemoryDetail: (id: string) => `${api_host}/memories/${id}`,
|
getMemoryDetail: (id: string) => `${api_host}/memories/${id}`,
|
||||||
updateMemorySetting: (id: string) => `${api_host}/memories/${id}`,
|
updateMemorySetting: (id: string) => `${api_host}/memories/${id}`,
|
||||||
deleteMemoryMessage: (data: { memory_id: string; message_id: string }) =>
|
deleteMemoryMessage: (data: { memory_id: string; message_id: string }) =>
|
||||||
|
|||||||
Reference in New Issue
Block a user