import HightLightMarkdown from '@/components/highlight-markdown'; import { ImageWithPopover } from '@/components/image'; import IndentedTree from '@/components/indented-tree/indented-tree'; import PdfDrawer from '@/components/pdf-drawer'; import { useClickDrawer } from '@/components/pdf-drawer/hooks'; import RetrievalDocuments from '@/components/retrieval-documents'; import { useSelectTestingResult } from '@/hooks/knowledge-hooks'; import { useGetPaginationWithRouter } from '@/hooks/logic-hooks'; import { IReference } from '@/interfaces/database/chat'; import { Card, Divider, Flex, Input, Layout, List, Pagination, PaginationProps, Skeleton, Space, Tag, } from 'antd'; import { useMemo, useState } from 'react'; import { useTranslation } from 'react-i18next'; import MarkdownContent from '../chat/markdown-content'; import { useFetchBackgroundImage, useSendQuestion } from './hooks'; import SearchSidebar from './sidebar'; import styles from './index.less'; const { Content } = Layout; const { Search } = Input; const SearchPage = () => { const { t } = useTranslation(); const [checkedList, setCheckedList] = useState([]); const { chunks, total } = useSelectTestingResult(); const { sendQuestion, handleClickRelatedQuestion, handleSearchStrChange, handleTestChunk, setSelectedDocumentIds, answer, sendingLoading, relatedQuestions, mindMap, mindMapLoading, searchStr, loading, isFirstRender, selectedDocumentIds, } = useSendQuestion(checkedList); const { visible, hideModal, documentId, selectedChunk, clickDocumentButton } = useClickDrawer(); const imgUrl = useFetchBackgroundImage(); const { pagination } = useGetPaginationWithRouter(); const onChange: PaginationProps['onChange'] = (pageNumber, pageSize) => { pagination.onChange?.(pageNumber, pageSize); handleTestChunk(selectedDocumentIds, pageNumber, pageSize); }; const isMindMapEmpty = useMemo(() => { return ( !mindMapLoading && ((Array.isArray(mindMap?.children) && mindMap.children.length === 0) || !Array.isArray(mindMap?.children)) ); }, [mindMap, mindMapLoading]); const InputSearch = ( ); return ( <> {isFirstRender ? ( {/* {appConf.appName} */} {InputSearch} ) : (
{InputSearch} {answer.answer && (
)} {chunks.length > 0 && ( ( {item.highlight} )} /> )} {relatedQuestions?.length > 0 && ( {relatedQuestions?.map((x, idx) => ( {x} ))} )}
{mindMapLoading ? ( ) : ( )}
)}
); }; export default SearchPage;