import FileIcon from '@/components/file-icon'; import HightLightMarkdown from '@/components/highlight-markdown'; import { ImageWithPopover } from '@/components/image'; import PdfDrawer from '@/components/pdf-drawer'; import { useClickDrawer } from '@/components/pdf-drawer/hooks'; import RetrievalDocuments from '@/components/retrieval-documents'; import SvgIcon from '@/components/svg-icon'; import { useFetchKnowledgeList, useSelectTestingResult, } from '@/hooks/knowledge-hooks'; import { useGetPaginationWithRouter } from '@/hooks/logic-hooks'; import { IReference } from '@/interfaces/database/chat'; import { Card, Divider, Flex, FloatButton, Input, Layout, List, Pagination, PaginationProps, Popover, Skeleton, Space, Spin, Tag, Tooltip, } from 'antd'; import DOMPurify from 'dompurify'; import { isEmpty } from 'lodash'; import { useMemo, useState } from 'react'; import { useTranslation } from 'react-i18next'; import MarkdownContent from '../chat/markdown-content'; import { useSendQuestion, useShowMindMapDrawer } from './hooks'; import styles from './index.less'; import MindMapDrawer from './mindmap-drawer'; import SearchSidebar from './sidebar'; const { Content } = Layout; const { Search } = Input; const SearchPage = () => { const { t } = useTranslation(); const [checkedList, setCheckedList] = useState([]); const { chunks, total } = useSelectTestingResult(); const { list: knowledgeList } = useFetchKnowledgeList(); const checkedWithoutEmbeddingIdList = useMemo(() => { return checkedList.filter((x) => knowledgeList.some((y) => y.id === x)); }, [checkedList, knowledgeList]); const { sendQuestion, handleClickRelatedQuestion, handleSearchStrChange, handleTestChunk, setSelectedDocumentIds, answer, sendingLoading, relatedQuestions, searchStr, loading, isFirstRender, selectedDocumentIds, isSearchStrEmpty, } = useSendQuestion(checkedWithoutEmbeddingIdList); const { visible, hideModal, documentId, selectedChunk, clickDocumentButton } = useClickDrawer(); const { pagination } = useGetPaginationWithRouter(); const { mindMapVisible, hideMindMapModal, showMindMapModal, mindMapLoading, mindMap, } = useShowMindMapDrawer(checkedWithoutEmbeddingIdList, searchStr); const onChange: PaginationProps['onChange'] = (pageNumber, pageSize) => { pagination.onChange?.(pageNumber, pageSize); handleTestChunk(selectedDocumentIds, pageNumber, pageSize); }; const InputSearch = ( ); return ( <> {isFirstRender ? ( {InputSearch} ) : (
{InputSearch} {t('chat.answerTitle')} } className={styles.answerWrapper} > {isEmpty(answer) && sendingLoading ? ( ) : ( answer.answer && ( ) )} {chunks?.length > 0 && ( ( {item.content_with_weight} } >
clickDocumentButton( item.doc_id, item as any, ) } > {item.docnm_kwd}
)} /> )}
{relatedQuestions?.length > 0 && ( {relatedQuestions?.map((x, idx) => ( {x} ))} )}
)}
{!isFirstRender && !isSearchStrEmpty && !isEmpty(checkedWithoutEmbeddingIdList) && ( } /> )} {visible && ( )} {mindMapVisible && ( )} ); }; export default SearchPage;