feat: Search for the answers you want based on the selected knowledge base #2247 (#2287)

### What problem does this PR solve?

feat: Search for the answers you want based on the selected knowledge
base #2247

### Type of change


- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
balibabu
2024-09-06 15:42:55 +08:00
committed by GitHub
parent b5a2711c05
commit 925dd2aa85
8 changed files with 46 additions and 103 deletions

View File

@ -1,6 +1,6 @@
import { ReactComponent as AssistantIcon } from '@/assets/svg/assistant.svg';
import { MessageType } from '@/constants/chat';
import { useSetModalState, useTranslate } from '@/hooks/common-hooks';
import { useSetModalState } from '@/hooks/common-hooks';
import { useSelectFileThumbnails } from '@/hooks/knowledge-hooks';
import { IReference } from '@/interfaces/database/chat';
import { IChunk } from '@/interfaces/database/knowledge';
@ -50,7 +50,6 @@ const MessageItem = ({
}: IProps) => {
const isAssistant = item.role === MessageType.Assistant;
const isUser = item.role === MessageType.User;
const { t } = useTranslate('chat');
const fileThumbnails = useSelectFileThumbnails();
const { data: documentList, setDocumentIds } = useFetchDocumentInfosByIds();
const { data: documentThumbnails, setDocumentIds: setIds } =
@ -62,14 +61,6 @@ const MessageItem = ({
return reference?.doc_aggs ?? [];
}, [reference?.doc_aggs]);
const content = useMemo(() => {
let text = item.content;
if (text === '') {
text = t('searching');
}
return loading ? text?.concat('~~2$$') : text;
}, [item.content, loading, t]);
const handleUserDocumentClick = useCallback(
(id: string) => () => {
setClickedDocumentId(id);
@ -154,7 +145,8 @@ const MessageItem = ({
}
>
<MarkdownContent
content={content}
loading={loading}
content={item.content}
reference={reference}
clickDocumentButton={clickDocumentButton}
></MarkdownContent>