File size: 4,339 Bytes
3927930 0dad3f5 3927930 0dad3f5 3927930 d4bff6a 3927930 71d280d f372e89 3927930 f372e89 e3239a2 3927930 f9e19e4 e68f488 f9e19e4 e68f488 0dad3f5 f9e19e4 3927930 0dad3f5 f372e89 3927930 0dad3f5 3927930 0dad3f5 f372e89 e3239a2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
import HightLightMarkdown from '@/components/highlight-markdown';
import { ImageWithPopover } from '@/components/image';
import IndentedTree from '@/components/indented-tree/indented-tree';
import { useSelectTestingResult } from '@/hooks/knowledge-hooks';
import { IReference } from '@/interfaces/database/chat';
import {
Card,
Divider,
Flex,
Input,
Layout,
List,
Skeleton,
Space,
Tag,
} from 'antd';
import { useState } from 'react';
import MarkdownContent from '../chat/markdown-content';
import { useSendQuestion } from './hooks';
import SearchSidebar from './sidebar';
import styles from './index.less';
const { Content } = Layout;
const { Search } = Input;
const SearchPage = () => {
const [checkedList, setCheckedList] = useState<string[]>([]);
const list = useSelectTestingResult();
const {
sendQuestion,
handleClickRelatedQuestion,
handleSearchStrChange,
answer,
sendingLoading,
relatedQuestions,
mindMap,
mindMapLoading,
searchStr,
loading,
isFirstRender,
} = useSendQuestion(checkedList);
const InputSearch = (
<Search
value={searchStr}
onChange={handleSearchStrChange}
placeholder="input search text"
allowClear
enterButton
onSearch={sendQuestion}
size="large"
loading={sendingLoading}
disabled={checkedList.length === 0}
className={isFirstRender ? styles.globalInput : styles.partialInput}
/>
);
return (
<Layout className={styles.searchPage}>
<SearchSidebar
checkedList={checkedList}
setCheckedList={setCheckedList}
></SearchSidebar>
<Layout>
<Content>
{isFirstRender ? (
<Flex
justify="center"
align="center"
className={styles.firstRenderContent}
>
{InputSearch}
</Flex>
) : (
<Flex className={styles.content}>
<section className={styles.main}>
{InputSearch}
{answer.answer && (
<div className={styles.answerWrapper}>
<MarkdownContent
loading={sendingLoading}
content={answer.answer}
reference={answer.reference ?? ({} as IReference)}
clickDocumentButton={() => {}}
></MarkdownContent>
</div>
)}
<Divider></Divider>
{list.chunks.length > 0 && (
<List
dataSource={list.chunks}
loading={loading}
renderItem={(item) => (
<List.Item>
<Card className={styles.card}>
<Space>
<ImageWithPopover
id={item.img_id}
></ImageWithPopover>
<HightLightMarkdown>
{item.highlight}
</HightLightMarkdown>
</Space>
</Card>
</List.Item>
)}
/>
)}
{relatedQuestions?.length > 0 && (
<Card>
<Flex wrap="wrap" gap={'10px 0'}>
{relatedQuestions?.map((x, idx) => (
<Tag
key={idx}
className={styles.tag}
onClick={handleClickRelatedQuestion(x)}
>
{x}
</Tag>
))}
</Flex>
</Card>
)}
</section>
<section className={styles.graph}>
{mindMapLoading ? (
<Skeleton active />
) : (
<IndentedTree
data={mindMap}
show
style={{ width: '100%', height: '100%' }}
></IndentedTree>
)}
</section>
</Flex>
)}
</Content>
</Layout>
</Layout>
);
};
export default SearchPage;
|