mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
Fix: File selection in Retrieval testing causes other options to disappear (#7759)
### What problem does this PR solve? https://github.com/infiniflow/ragflow/issues/7753 The internal is due to when the selected row keys change will trigger a testing, but I do not know why. ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
@ -261,6 +261,51 @@ export const useTestChunkRetrieval = (): ResponsePostType<ITestingResult> & {
|
||||
};
|
||||
};
|
||||
|
||||
export const useTestChunkAllRetrieval = (): ResponsePostType<ITestingResult> & {
|
||||
testChunkAll: (...params: any[]) => void;
|
||||
} => {
|
||||
const knowledgeBaseId = useKnowledgeBaseId();
|
||||
const { page, size: pageSize } = useSetPaginationParams();
|
||||
|
||||
const {
|
||||
data,
|
||||
isPending: loading,
|
||||
mutateAsync,
|
||||
} = useMutation({
|
||||
mutationKey: ['testChunkAll'], // This method is invalid
|
||||
gcTime: 0,
|
||||
mutationFn: async (values: any) => {
|
||||
const { data } = await kbService.retrieval_test({
|
||||
...values,
|
||||
kb_id: values.kb_id ?? knowledgeBaseId,
|
||||
doc_ids: [],
|
||||
page,
|
||||
size: pageSize,
|
||||
});
|
||||
if (data.code === 0) {
|
||||
const res = data.data;
|
||||
return {
|
||||
...res,
|
||||
documents: res.doc_aggs,
|
||||
};
|
||||
}
|
||||
return (
|
||||
data?.data ?? {
|
||||
chunks: [],
|
||||
documents: [],
|
||||
total: 0,
|
||||
}
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
return {
|
||||
data: data ?? { chunks: [], documents: [], total: 0 },
|
||||
loading,
|
||||
testChunkAll: mutateAsync,
|
||||
};
|
||||
};
|
||||
|
||||
export const useChunkIsTesting = () => {
|
||||
return useIsMutating({ mutationKey: ['testChunk'] }) > 0;
|
||||
};
|
||||
@ -288,6 +333,30 @@ export const useSelectIsTestingSuccess = () => {
|
||||
});
|
||||
return status.at(-1) === 'success';
|
||||
};
|
||||
|
||||
export const useAllTestingSuccess = () => {
|
||||
const status = useMutationState({
|
||||
filters: { mutationKey: ['testChunkAll'] },
|
||||
select: (mutation) => {
|
||||
return mutation.state.status;
|
||||
},
|
||||
});
|
||||
return status.at(-1) === 'success';
|
||||
};
|
||||
|
||||
export const useAllTestingResult = (): ITestingResult => {
|
||||
const data = useMutationState({
|
||||
filters: { mutationKey: ['testChunkAll'] },
|
||||
select: (mutation) => {
|
||||
return mutation.state.data;
|
||||
},
|
||||
});
|
||||
return (data.at(-1) ?? {
|
||||
chunks: [],
|
||||
documents: [],
|
||||
total: 0,
|
||||
}) as ITestingResult;
|
||||
};
|
||||
//#endregion
|
||||
|
||||
//#region tags
|
||||
|
||||
Reference in New Issue
Block a user