From 5089d86095eddf0a4e3b65802175c22ee1acbc2e Mon Sep 17 00:00:00 2001 From: ManishMadan2882 Date: Fri, 28 Mar 2025 18:12:38 +0530 Subject: [PATCH] (feat:attach) send attachment ids --- frontend/src/conversation/conversationHandlers.ts | 14 ++++++++++++++ frontend/src/conversation/conversationSlice.ts | 6 ++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/frontend/src/conversation/conversationHandlers.ts b/frontend/src/conversation/conversationHandlers.ts index 88771fc5..1a5d72db 100644 --- a/frontend/src/conversation/conversationHandlers.ts +++ b/frontend/src/conversation/conversationHandlers.ts @@ -13,6 +13,7 @@ export function handleFetchAnswer( promptId: string | null, chunks: string, token_limit: number, + attachments?: string[], ): Promise< | { result: any; @@ -48,6 +49,12 @@ export function handleFetchAnswer( token_limit: token_limit, isNoneDoc: selectedDocs === null, }; + + // Add attachments to payload if they exist + if (attachments && attachments.length > 0) { + payload.attachments = attachments; + } + if (selectedDocs && 'id' in selectedDocs) { payload.active_docs = selectedDocs.id as string; } @@ -86,6 +93,7 @@ export function handleFetchAnswerSteaming( token_limit: number, onEvent: (event: MessageEvent) => void, indx?: number, + attachments?: string[], ): Promise { history = history.map((item) => { return { @@ -104,6 +112,12 @@ export function handleFetchAnswerSteaming( isNoneDoc: selectedDocs === null, index: indx, }; + + // Add attachments to payload if they exist + if (attachments && attachments.length > 0) { + payload.attachments = attachments; + } + if (selectedDocs && 'id' in selectedDocs) { payload.active_docs = selectedDocs.id as string; } diff --git a/frontend/src/conversation/conversationSlice.ts b/frontend/src/conversation/conversationSlice.ts index 7cd14d5e..ecd7ef84 100644 --- a/frontend/src/conversation/conversationSlice.ts +++ b/frontend/src/conversation/conversationSlice.ts @@ -27,8 +27,8 @@ export function handleAbort() { export const fetchAnswer = createAsyncThunk< Answer, - { question: string; indx?: number } ->('fetchAnswer', async ({ question, indx }, { dispatch, getState }) => { + { question: string; indx?: number; attachments?: string[] } +>('fetchAnswer', async ({ question, indx, attachments }, { dispatch, getState }) => { if (abortController) { abortController.abort(); } @@ -110,6 +110,7 @@ export const fetchAnswer = createAsyncThunk< } }, indx, + attachments ); } else { const answer = await handleFetchAnswer( @@ -122,6 +123,7 @@ export const fetchAnswer = createAsyncThunk< state.preference.prompt.id, state.preference.chunks, state.preference.token_limit, + attachments ); if (answer) { let sourcesPrepped = [];