ragflow/web/src/pages/next-chats/hooks/use-set-conversation.ts
balibabu bed77ee28f
Feat: Create a conversation before uploading files #3221 (#9832)
### What problem does this PR solve?

Feat: Create a conversation before uploading files #3221

### Type of change


- [x] New Feature (non-breaking change which adds functionality)
2025-08-29 18:36:40 +08:00

35 lines
872 B
TypeScript

import { MessageType } from '@/constants/chat';
import { useUpdateConversation } from '@/hooks/use-chat-request';
import { useCallback } from 'react';
import { useParams } from 'umi';
export const useSetConversation = () => {
const { id: dialogId } = useParams();
const { updateConversation } = useUpdateConversation();
const setConversation = useCallback(
async (
message: string,
isNew: boolean = false,
conversationId?: string,
) => {
const data = await updateConversation({
dialog_id: dialogId,
name: message,
is_new: isNew,
conversation_id: conversationId,
message: [
{
role: MessageType.Assistant,
content: message,
},
],
});
return data;
},
[updateConversation, dialogId],
);
return { setConversation };
};