From 430822bae357f2ea644953854fb35b9a9b3a60d5 Mon Sep 17 00:00:00 2001 From: ManishMadan2882 Date: Fri, 6 Jun 2025 18:54:50 +0530 Subject: [PATCH] (feat:attach)state manage, follow camelCase --- application/api/user/routes.py | 2 +- frontend/src/conversation/Conversation.tsx | 16 ++++++++++++++-- frontend/src/conversation/ConversationBubble.tsx | 4 ++-- frontend/src/conversation/conversationModels.ts | 2 +- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/application/api/user/routes.py b/application/api/user/routes.py index 518c1382..161b0765 100644 --- a/application/api/user/routes.py +++ b/application/api/user/routes.py @@ -267,7 +267,7 @@ class GetSingleConversation(Resource): if attachment: attachment_details.append({ "id": str(attachment["_id"]), - "filename": attachment.get("filename", "Unknown file") + "fileName": attachment.get("filename", "Unknown file") }) except Exception as e: current_app.logger.error( diff --git a/frontend/src/conversation/Conversation.tsx b/frontend/src/conversation/Conversation.tsx index 4f34c26c..c433514f 100644 --- a/frontend/src/conversation/Conversation.tsx +++ b/frontend/src/conversation/Conversation.tsx @@ -27,6 +27,7 @@ import { setConversation, updateConversationId, updateQuery, + selectAttachments, } from './conversationSlice'; export default function Conversation() { @@ -39,6 +40,7 @@ export default function Conversation() { const status = useSelector(selectStatus); const conversationId = useSelector(selectConversationId); const selectedAgent = useSelector(selectSelectedAgent); + const attachments = useSelector(selectAttachments); const [uploadModalState, setUploadModalState] = useState('INACTIVE'); @@ -107,15 +109,25 @@ export default function Conversation() { const trimmedQuestion = question.trim(); if (trimmedQuestion === '') return; + const attachmentMetadata = attachments + .filter((a) => a.id && a.status === 'completed') + .map((a) => ({ id: a.id as string, fileName: a.fileName })); + if (index !== undefined) { if (!isRetry) dispatch(resendQuery({ index, prompt: trimmedQuestion })); handleFetchAnswer({ question: trimmedQuestion, index }); } else { - if (!isRetry) dispatch(addQuery({ prompt: trimmedQuestion })); + if (!isRetry) + dispatch( + addQuery({ + prompt: trimmedQuestion, + attachments: attachmentMetadata, + }), + ); handleFetchAnswer({ question: trimmedQuestion, index }); } }, - [dispatch, handleFetchAnswer], + [dispatch, handleFetchAnswer, attachments], ); const handleFeedback = (query: Query, feedback: FEEDBACK, index: number) => { diff --git a/frontend/src/conversation/ConversationBubble.tsx b/frontend/src/conversation/ConversationBubble.tsx index 93edfc9a..c850ad01 100644 --- a/frontend/src/conversation/ConversationBubble.tsx +++ b/frontend/src/conversation/ConversationBubble.tsx @@ -59,7 +59,7 @@ const ConversationBubble = forwardRef< updated?: boolean, index?: number, ) => void; - attachmentsMetadata?: { id: string; filename: string }[]; + attachmentsMetadata?: { id: string; fileName: string }[]; } >(function ConversationBubble( { @@ -124,7 +124,7 @@ const ConversationBubble = forwardRef< /> - {attachment.filename} + {attachment.fileName} ))} diff --git a/frontend/src/conversation/conversationModels.ts b/frontend/src/conversation/conversationModels.ts index b9abf853..f0ccca05 100644 --- a/frontend/src/conversation/conversationModels.ts +++ b/frontend/src/conversation/conversationModels.ts @@ -46,7 +46,7 @@ export interface Query { sources?: { title: string; text: string; link: string }[]; tool_calls?: ToolCallsType[]; error?: string; - attachments?: { id: string; filename: string }[]; + attachments?: { id: string; fileName: string }[]; } export interface RetrievalPayload {