2024-09-05 19:32:55 +08:00
|
|
|
import HightLightMarkdown from '@/components/highlight-markdown';
|
|
|
|
|
import { ImageWithPopover } from '@/components/image';
|
|
|
|
|
import { useSelectTestingResult } from '@/hooks/knowledge-hooks';
|
|
|
|
|
import { IReference } from '@/interfaces/database/chat';
|
2024-09-06 19:56:17 +08:00
|
|
|
import { Card, Flex, Input, Layout, List, Skeleton, Space, Tag } from 'antd';
|
2024-09-05 19:32:55 +08:00
|
|
|
import { useState } from 'react';
|
2024-09-06 15:42:55 +08:00
|
|
|
import MarkdownContent from '../chat/markdown-content';
|
2024-09-05 19:32:55 +08:00
|
|
|
import { useSendQuestion } from './hooks';
|
2024-09-05 16:04:04 +08:00
|
|
|
import SearchSidebar from './sidebar';
|
2024-09-05 12:12:44 +08:00
|
|
|
|
2024-09-06 19:56:17 +08:00
|
|
|
import IndentedTree from '@/components/indented-tree/indented-tree';
|
2024-09-05 19:32:55 +08:00
|
|
|
import styles from './index.less';
|
|
|
|
|
|
|
|
|
|
const { Content } = Layout;
|
|
|
|
|
const { Search } = Input;
|
2024-09-05 12:12:44 +08:00
|
|
|
|
2024-09-05 09:33:05 +08:00
|
|
|
const SearchPage = () => {
|
2024-09-05 19:32:55 +08:00
|
|
|
const [checkedList, setCheckedList] = useState<string[]>([]);
|
|
|
|
|
const list = useSelectTestingResult();
|
2024-09-06 19:56:17 +08:00
|
|
|
const {
|
|
|
|
|
sendQuestion,
|
|
|
|
|
answer,
|
|
|
|
|
sendingLoading,
|
|
|
|
|
relatedQuestions,
|
|
|
|
|
mindMap,
|
|
|
|
|
mindMapLoading,
|
|
|
|
|
} = useSendQuestion(checkedList);
|
2024-09-05 19:32:55 +08:00
|
|
|
|
2024-09-05 12:12:44 +08:00
|
|
|
return (
|
2024-09-05 19:32:55 +08:00
|
|
|
<Layout className={styles.searchPage}>
|
|
|
|
|
<SearchSidebar
|
|
|
|
|
checkedList={checkedList}
|
|
|
|
|
setCheckedList={setCheckedList}
|
|
|
|
|
></SearchSidebar>
|
|
|
|
|
<Layout>
|
|
|
|
|
<Content>
|
|
|
|
|
<Flex className={styles.content}>
|
|
|
|
|
<section className={styles.main}>
|
|
|
|
|
<Search
|
|
|
|
|
placeholder="input search text"
|
|
|
|
|
onSearch={sendQuestion}
|
|
|
|
|
size="large"
|
2024-09-06 15:42:55 +08:00
|
|
|
loading={sendingLoading}
|
|
|
|
|
disabled={checkedList.length === 0}
|
2024-09-05 19:32:55 +08:00
|
|
|
/>
|
2024-09-06 15:42:55 +08:00
|
|
|
<MarkdownContent
|
2024-09-05 19:32:55 +08:00
|
|
|
loading={sendingLoading}
|
2024-09-06 15:42:55 +08:00
|
|
|
content={answer.answer}
|
|
|
|
|
reference={answer.reference ?? ({} as IReference)}
|
|
|
|
|
clickDocumentButton={() => {}}
|
|
|
|
|
></MarkdownContent>
|
2024-09-05 19:32:55 +08:00
|
|
|
<List
|
|
|
|
|
dataSource={list.chunks}
|
|
|
|
|
renderItem={(item) => (
|
|
|
|
|
<List.Item>
|
2024-09-06 15:42:55 +08:00
|
|
|
<Card className={styles.card}>
|
2024-09-05 19:32:55 +08:00
|
|
|
<Space>
|
|
|
|
|
<ImageWithPopover id={item.img_id}></ImageWithPopover>
|
|
|
|
|
<HightLightMarkdown>
|
|
|
|
|
{item.highlight}
|
|
|
|
|
</HightLightMarkdown>
|
|
|
|
|
</Space>
|
|
|
|
|
</Card>
|
|
|
|
|
</List.Item>
|
|
|
|
|
)}
|
|
|
|
|
/>
|
2024-09-06 19:56:17 +08:00
|
|
|
{relatedQuestions?.length > 0 && (
|
|
|
|
|
<Card>
|
|
|
|
|
<Flex wrap="wrap" gap={'10px 0'}>
|
|
|
|
|
{relatedQuestions?.map((x, idx) => (
|
|
|
|
|
<Tag key={idx} className={styles.tag}>
|
|
|
|
|
{x}
|
|
|
|
|
</Tag>
|
|
|
|
|
))}
|
|
|
|
|
</Flex>
|
|
|
|
|
</Card>
|
|
|
|
|
)}
|
|
|
|
|
</section>
|
|
|
|
|
<section className={styles.graph}>
|
|
|
|
|
{mindMapLoading ? (
|
|
|
|
|
<Skeleton active />
|
|
|
|
|
) : (
|
|
|
|
|
<IndentedTree
|
|
|
|
|
data={mindMap}
|
|
|
|
|
show
|
|
|
|
|
style={{ width: '100%', height: '100%' }}
|
|
|
|
|
></IndentedTree>
|
|
|
|
|
)}
|
2024-09-05 19:32:55 +08:00
|
|
|
</section>
|
|
|
|
|
</Flex>
|
2024-09-05 12:12:44 +08:00
|
|
|
</Content>
|
|
|
|
|
</Layout>
|
|
|
|
|
</Layout>
|
|
|
|
|
);
|
2024-09-05 09:33:05 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default SearchPage;
|