Feat: Delete useless knowledge base, chat, and search files. #10427 (#11568)

### What problem does this PR solve?

Feat: Delete useless knowledge base, chat, and search files.  #10427
### Type of change


- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
balibabu
2025-11-27 17:54:27 +08:00
committed by GitHub
parent c71d25f744
commit 89d82ff031
171 changed files with 161 additions and 11112 deletions

View File

@ -1,5 +1,6 @@
import message from '@/components/ui/message';
import { SharedFrom } from '@/constants/chat';
import { useSetModalState } from '@/hooks/common-hooks';
import { useSelectTestingResult } from '@/hooks/knowledge-hooks';
import {
useGetPaginationWithRouter,
@ -16,18 +17,18 @@ import kbService from '@/services/knowledge-service';
import searchService from '@/services/search-service';
import api from '@/utils/api';
import { useMutation } from '@tanstack/react-query';
import { has, isEmpty, trim } from 'lodash';
import { has, isEmpty, isEqual, trim } from 'lodash';
import {
ChangeEventHandler,
Dispatch,
SetStateAction,
useCallback,
useEffect,
useRef,
useState,
} from 'react';
import { useSearchParams } from 'umi';
import { ISearchAppDetailProps } from '../next-searches/hooks';
import { useShowMindMapDrawer } from '../search/hooks';
import { useClickDrawer } from './document-preview-modal/hooks';
export interface ISearchingProps {
@ -90,6 +91,41 @@ export const useSearchFetchMindMap = () => {
return { data, loading, fetchMindMap: mutateAsync };
};
export const useShowMindMapDrawer = (
kbIds: string[],
question: string,
searchId = '',
) => {
const { visible, showModal, hideModal } = useSetModalState();
const ref = useRef<any>();
const {
fetchMindMap,
data: mindMap,
loading: mindMapLoading,
} = useSearchFetchMindMap();
const handleShowModal = useCallback(() => {
const searchParams = { question: trim(question), kb_ids: kbIds, searchId };
if (
!isEmpty(searchParams.question) &&
!isEqual(searchParams, ref.current)
) {
ref.current = searchParams;
fetchMindMap(searchParams);
}
showModal();
}, [fetchMindMap, showModal, question, kbIds, searchId]);
return {
mindMap,
mindMapVisible: visible,
mindMapLoading,
showMindMapModal: handleShowModal,
hideMindMapModal: hideModal,
};
};
export const useTestChunkRetrieval = (
tenantId?: string,
): ResponsePostType<ITestingResult> & {
@ -539,3 +575,28 @@ export const useCheckSettings = (data: ISearchAppDetailProps) => {
openSetting: kb_ids && kb_ids.length > 0 && name ? false : true,
};
};
export const usePendingMindMap = () => {
const [count, setCount] = useState<number>(0);
const ref = useRef<NodeJS.Timeout>();
const setCountInterval = useCallback(() => {
ref.current = setInterval(() => {
setCount((pre) => {
if (pre > 40) {
clearInterval(ref?.current);
}
return pre + 1;
});
}, 1000);
}, []);
useEffect(() => {
setCountInterval();
return () => {
clearInterval(ref?.current);
};
}, [setCountInterval]);
return Number(((count / 43) * 100).toFixed(0));
};

View File

@ -20,7 +20,9 @@ import { useTranslation } from 'react-i18next';
import 'katex/dist/katex.min.css'; // `rehype-katex` does not import the CSS for you
import {
currentReg,
preprocessLaTeX,
replaceTextByOldReg,
replaceThinkToSection,
showImage,
} from '@/utils/chat';
@ -31,7 +33,6 @@ import {
PopoverContent,
PopoverTrigger,
} from '@/components/ui/popover';
import { currentReg, replaceTextByOldReg } from '@/pages/next-chats/utils';
import classNames from 'classnames';
import { omit } from 'lodash';
import { pipe } from 'lodash/fp';

View File

@ -3,7 +3,7 @@ import { Progress } from '@/components/ui/progress';
import { IModalProps } from '@/interfaces/common';
import { X } from 'lucide-react';
import { useTranslation } from 'react-i18next';
import { usePendingMindMap } from '../search/hooks';
import { usePendingMindMap } from './hooks';
interface IProps extends IModalProps<any> {
data: any;