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 { useNextFetchKnowledgeList, 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, Popover, 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 { list: knowledgeList } = useNextFetchKnowledgeList(); const checkedWithoutEmbeddingIdList = useMemo(() => { return checkedList.filter((x) => knowledgeList.some((y) => y.id === x)); }, [checkedList, knowledgeList]); const { sendQuestion, handleClickRelatedQuestion, handleSearchStrChange, handleTestChunk, setSelectedDocumentIds, answer, sendingLoading, relatedQuestions, mindMap, mindMapLoading, searchStr, loading, isFirstRender, selectedDocumentIds, } = useSendQuestion(checkedWithoutEmbeddingIdList); 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 ? ( {InputSearch} ) : (
{InputSearch} {answer.answer && (
)} {chunks.length > 0 && ( ( clickDocumentButton(item.doc_id, item as any) } > {item.content_with_weight} } >
{item.highlight}
)} /> )} {relatedQuestions?.length > 0 && ( {relatedQuestions?.map((x, idx) => ( {x} ))} )}
{mindMapLoading ? ( ) : ( )}
)}
); }; export default SearchPage;