fix: fixed the issue that the prompt word for registering an account is not in English and fixed the issue where the last message would keep loading if the backend reported an error during chat and fixed the issue where the next button would float above the file list on the file upload page (#133)

* feat: fixed the issue where the next button would float above the file list on the file upload page.

* feat: fixed the issue where the last message would keep loading if the backend reported an error during chat.

* fix: fixed the issue that the prompt word for registering an account is not in English
This commit is contained in:
balibabu
2024-03-19 19:21:35 +08:00
committed by GitHub
parent 9a843667b3
commit d38e92aac8
7 changed files with 107 additions and 42 deletions

View File

@ -4,7 +4,6 @@ import NewDocumentLink from '@/components/new-document-link';
import DocumentPreviewer from '@/components/pdf-previewer';
import { MessageType } from '@/constants/chat';
import { useSelectFileThumbnails } from '@/hooks/knowledgeHook';
import { useOneNamespaceEffectsLoading } from '@/hooks/storeHooks';
import { useSelectUserInfo } from '@/hooks/userSettingHook';
import { IReference, Message } from '@/interfaces/database/chat';
import { IChunk } from '@/interfaces/database/knowledge';
@ -21,7 +20,7 @@ import {
Space,
} from 'antd';
import classNames from 'classnames';
import { ChangeEventHandler, useCallback, useMemo, useState } from 'react';
import { useCallback, useMemo } from 'react';
import Markdown from 'react-markdown';
import reactStringReplace from 'react-string-replace';
import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';
@ -243,35 +242,19 @@ const MessageItem = ({
};
const ChatContainer = () => {
const [value, setValue] = useState('');
const {
ref,
currentConversation: conversation,
addNewestConversation,
removeLatestMessage,
} = useFetchConversationOnMount();
const { sendMessage } = useSendMessage();
const { handleInputChange, handlePressEnter, value, loading } =
useSendMessage(conversation, addNewestConversation, removeLatestMessage);
const { visible, hideModal, documentId, selectedChunk, clickDocumentButton } =
useClickDrawer();
const loading = useOneNamespaceEffectsLoading('chatModel', [
'completeConversation',
]);
useGetFileIcon();
const handlePressEnter = () => {
if (!loading) {
setValue('');
addNewestConversation(value);
sendMessage(value.trim());
}
};
const handleInputChange: ChangeEventHandler<HTMLInputElement> = (e) => {
const value = e.target.value;
const nextValue = value.replaceAll('\\n', '\n').replaceAll('\\t', '\t');
setValue(nextValue);
};
return (
<>
<Flex flex={1} className={styles.chatContainer} vertical>