ragflow/web/src/pages/datasets/hooks.ts
chanx e82617f6de
feat(dataset): Added data pipeline configuration functionality #9869 (#10132)
### What problem does this PR solve?

feat(dataset): Added data pipeline configuration functionality #9869

- Added a data pipeline selection component to link data pipelines with
knowledge bases
- Added file filtering functionality, supporting custom file filtering
rules
- Optimized the configuration interface layout, adjusting style and
spacing
- Introduced new icons and buttons to enhance the user experience

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
2025-09-18 09:31:57 +08:00

46 lines
1.2 KiB
TypeScript

import { useSetModalState } from '@/hooks/common-hooks';
import { useNavigatePage } from '@/hooks/logic-hooks/navigate-hooks';
import { useCreateKnowledge } from '@/hooks/use-knowledge-request';
import { useCallback, useState } from 'react';
export const useSearchKnowledge = () => {
const [searchString, setSearchString] = useState<string>('');
const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
setSearchString(e.target.value);
};
return {
searchString,
handleInputChange,
};
};
export interface Iknowledge {
name: string;
embd_id: string;
parser_id: string;
}
export const useSaveKnowledge = () => {
const { visible: visible, hideModal, showModal } = useSetModalState();
const { loading, createKnowledge } = useCreateKnowledge();
const { navigateToDataset } = useNavigatePage();
const onCreateOk = useCallback(
async (data: Iknowledge) => {
const ret = await createKnowledge(data);
if (ret?.code === 0) {
hideModal();
navigateToDataset(ret.data.kb_id)();
}
},
[createKnowledge, hideModal, navigateToDataset],
);
return {
loading,
onCreateOk,
visible,
hideModal,
showModal,
};
};