2024-09-05 19:32:55 +08:00
|
|
|
import HightLightMarkdown from '@/components/highlight-markdown';
|
|
|
|
|
import { ImageWithPopover } from '@/components/image';
|
|
|
|
|
import MessageItem from '@/components/message-item';
|
|
|
|
|
import { useSelectTestingResult } from '@/hooks/knowledge-hooks';
|
|
|
|
|
import { IReference } from '@/interfaces/database/chat';
|
|
|
|
|
import { Card, Flex, Input, Layout, List, Space } from 'antd';
|
|
|
|
|
import { useState } from 'react';
|
|
|
|
|
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-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();
|
|
|
|
|
const { sendQuestion, message, sendingLoading } =
|
|
|
|
|
useSendQuestion(checkedList);
|
|
|
|
|
|
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"
|
|
|
|
|
/>
|
|
|
|
|
<MessageItem
|
|
|
|
|
item={message}
|
|
|
|
|
nickname="You"
|
|
|
|
|
reference={message.reference ?? ({} as IReference)}
|
|
|
|
|
loading={sendingLoading}
|
|
|
|
|
index={0}
|
|
|
|
|
></MessageItem>
|
|
|
|
|
<List
|
|
|
|
|
dataSource={list.chunks}
|
|
|
|
|
renderItem={(item) => (
|
|
|
|
|
<List.Item>
|
|
|
|
|
<Card>
|
|
|
|
|
<Space>
|
|
|
|
|
<ImageWithPopover id={item.img_id}></ImageWithPopover>
|
|
|
|
|
<HightLightMarkdown>
|
|
|
|
|
{item.highlight}
|
|
|
|
|
</HightLightMarkdown>
|
|
|
|
|
</Space>
|
|
|
|
|
</Card>
|
|
|
|
|
</List.Item>
|
|
|
|
|
)}
|
|
|
|
|
/>
|
|
|
|
|
</section>
|
|
|
|
|
<section className={styles.graph}></section>
|
|
|
|
|
</Flex>
|
2024-09-05 12:12:44 +08:00
|
|
|
</Content>
|
|
|
|
|
</Layout>
|
|
|
|
|
</Layout>
|
|
|
|
|
);
|
2024-09-05 09:33:05 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default SearchPage;
|