mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-23 23:16:58 +08:00
### What problem does this PR solve? feat: Create a conversation before uploading files in it #1880 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
@ -4,6 +4,7 @@ import { MessageType } from '@/constants/chat';
|
||||
import { Drawer, Flex, Spin } from 'antd';
|
||||
import {
|
||||
useClickDrawer,
|
||||
useCreateConversationBeforeUploadDocument,
|
||||
useFetchConversationOnMount,
|
||||
useGetFileIcon,
|
||||
useGetSendButtonDisabled,
|
||||
@ -24,6 +25,7 @@ const ChatContainer = () => {
|
||||
addNewestConversation,
|
||||
removeLatestMessage,
|
||||
addNewestAnswer,
|
||||
conversationId,
|
||||
} = useFetchConversationOnMount();
|
||||
const {
|
||||
handleInputChange,
|
||||
@ -43,6 +45,8 @@ const ChatContainer = () => {
|
||||
useGetFileIcon();
|
||||
const loading = useSelectConversationLoading();
|
||||
const { data: userInfo } = useFetchUserInfo();
|
||||
const { createConversationBeforeUploadDocument } =
|
||||
useCreateConversationBeforeUploadDocument();
|
||||
|
||||
return (
|
||||
<>
|
||||
@ -78,7 +82,10 @@ const ChatContainer = () => {
|
||||
value={value}
|
||||
onInputChange={handleInputChange}
|
||||
onPressEnter={handlePressEnter}
|
||||
conversationId={conversation.id}
|
||||
conversationId={conversationId}
|
||||
createConversationBeforeUploadDocument={
|
||||
createConversationBeforeUploadDocument
|
||||
}
|
||||
></MessageInput>
|
||||
</Flex>
|
||||
<Drawer
|
||||
|
||||
@ -520,6 +520,7 @@ export const useFetchConversationOnMount = () => {
|
||||
ref,
|
||||
removeLatestMessage,
|
||||
addNewestAnswer,
|
||||
conversationId,
|
||||
};
|
||||
};
|
||||
|
||||
@ -769,4 +770,28 @@ export const useGetSendButtonDisabled = () => {
|
||||
export const useSendButtonDisabled = (value: string) => {
|
||||
return trim(value) === '';
|
||||
};
|
||||
|
||||
export const useCreateConversationBeforeUploadDocument = () => {
|
||||
const { setConversation } = useSetConversation();
|
||||
const { dialogId } = useGetChatSearchParams();
|
||||
|
||||
const { handleClickConversation } = useClickConversationCard();
|
||||
|
||||
const createConversationBeforeUploadDocument = useCallback(
|
||||
async (message: string) => {
|
||||
const data = await setConversation(message);
|
||||
if (data.retcode === 0) {
|
||||
const id = data.data.id;
|
||||
handleClickConversation(id);
|
||||
}
|
||||
return data;
|
||||
},
|
||||
[setConversation, handleClickConversation],
|
||||
);
|
||||
|
||||
return {
|
||||
createConversationBeforeUploadDocument,
|
||||
dialogId,
|
||||
};
|
||||
};
|
||||
//#endregion
|
||||
|
||||
@ -75,7 +75,7 @@ const ChatContainer = () => {
|
||||
onInputChange={handleInputChange}
|
||||
onPressEnter={handlePressEnter}
|
||||
sendLoading={sendLoading}
|
||||
uploadUrl="/v1/api/document/upload_and_parse"
|
||||
uploadMethod="external_upload_and_parse"
|
||||
showUploadIcon={from === SharedFrom.Chat}
|
||||
></MessageInput>
|
||||
</Flex>
|
||||
|
||||
Reference in New Issue
Block a user