mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
feat: create chunk and edit chunk and delete chunk (#58)
* feat: create chunk and edit chunk * feat: delete chunk * feat: search chunks * feat: delete chunks in batches * feat: set whether chunks are available in batches
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
import showDeleteConfirm from '@/components/deleting-confirm';
|
||||
import { IKnowledge } from '@/interfaces/database/knowledge';
|
||||
import { useCallback } from 'react';
|
||||
import { useDispatch, useSearchParams, useSelector } from 'umi';
|
||||
|
||||
export const useKnowledgeBaseId = (): string => {
|
||||
@ -46,3 +47,33 @@ export const useGetDocumentDefaultParser = (knowledgeBaseId: string) => {
|
||||
parserConfig: item?.parser_config ?? '',
|
||||
};
|
||||
};
|
||||
|
||||
export const useDeleteChunkByIds = (): {
|
||||
removeChunk: (chunkIds: string[], documentId: string) => Promise<number>;
|
||||
} => {
|
||||
const dispatch = useDispatch();
|
||||
|
||||
const removeChunk = useCallback(
|
||||
(chunkIds: string[], documentId: string) => () => {
|
||||
return dispatch({
|
||||
type: 'chunkModel/rm_chunk',
|
||||
payload: {
|
||||
chunk_ids: chunkIds,
|
||||
doc_id: documentId,
|
||||
},
|
||||
});
|
||||
},
|
||||
[dispatch],
|
||||
);
|
||||
|
||||
const onRemoveChunk = useCallback(
|
||||
(chunkIds: string[], documentId: string): Promise<number> => {
|
||||
return showDeleteConfirm({ onOk: removeChunk(chunkIds, documentId) });
|
||||
},
|
||||
[removeChunk],
|
||||
);
|
||||
|
||||
return {
|
||||
removeChunk: onRemoveChunk,
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user