feat: add batch operations for document list (#302)

### What problem does this PR solve?

document list needs to be batch operated


Issue link: #301

### Type of change

- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
balibabu
2024-04-10 17:17:41 +08:00
committed by GitHub
parent 1ff5d9d55b
commit 533ac3b534
16 changed files with 341 additions and 143 deletions

View File

@ -155,23 +155,26 @@ export const useSetDocumentParser = () => {
return setDocumentParser;
};
export const useRemoveDocument = (documentId: string) => {
export const useRemoveDocument = () => {
const dispatch = useDispatch();
const { knowledgeId } = useGetKnowledgeSearchParams();
const removeDocument = useCallback(() => {
try {
return dispatch<any>({
type: 'kFModel/document_rm',
payload: {
doc_id: documentId,
kb_id: knowledgeId,
},
});
} catch (errorInfo) {
console.log('Failed:', errorInfo);
}
}, [dispatch, knowledgeId, documentId]);
const removeDocument = useCallback(
(documentId: string) => {
try {
return dispatch<any>({
type: 'kFModel/document_rm',
payload: {
doc_id: documentId,
kb_id: knowledgeId,
},
});
} catch (errorInfo) {
console.log('Failed:', errorInfo);
}
},
[dispatch, knowledgeId],
);
return removeDocument;
};
@ -204,11 +207,11 @@ export const useRunDocument = () => {
const dispatch = useDispatch();
const runDocumentByIds = useCallback(
(ids: string[]) => {
(payload: any) => {
try {
return dispatch<any>({
type: 'kFModel/document_run',
payload: { doc_ids: ids, run: 1 },
payload,
});
} catch (errorInfo) {
console.log('Failed:', errorInfo);