From 644a66c983bd87e91f275880c4b7834d25b27f71 Mon Sep 17 00:00:00 2001 From: Mayurakshi Date: Mon, 14 Oct 2024 16:53:40 +0530 Subject: [PATCH] Fix: Pass retriever name to streaming api --- .../src/conversation/conversationHandlers.ts | 33 +++++-------------- .../src/conversation/conversationModels.ts | 1 + 2 files changed, 10 insertions(+), 24 deletions(-) diff --git a/frontend/src/conversation/conversationHandlers.ts b/frontend/src/conversation/conversationHandlers.ts index 338ed864..e28e4b22 100644 --- a/frontend/src/conversation/conversationHandlers.ts +++ b/frontend/src/conversation/conversationHandlers.ts @@ -38,9 +38,11 @@ export function handleFetchAnswer( prompt_id: promptId, chunks: chunks, token_limit: token_limit, + isNoneDoc: selectedDocs === null, }; - if (selectedDocs && 'id' in selectedDocs) + if (selectedDocs && 'id' in selectedDocs) { payload.active_docs = selectedDocs.id as string; + } payload.retriever = selectedDocs?.retriever as string; return conversationService .answer(payload, signal) @@ -84,26 +86,16 @@ export function handleFetchAnswerSteaming( prompt_id: promptId, chunks: chunks, token_limit: token_limit, + isNoneDoc: selectedDocs === null, }; - if (selectedDocs && 'id' in selectedDocs) + if (selectedDocs && 'id' in selectedDocs) { payload.active_docs = selectedDocs.id as string; + } payload.retriever = selectedDocs?.retriever as string; return new Promise((resolve, reject) => { conversationService - .answerStream( - { - question: question, - active_docs: selectedDocs?.id as string, - history: JSON.stringify(history), - conversation_id: conversationId, - prompt_id: promptId, - chunks: chunks, - token_limit: token_limit, - isNoneDoc: selectedDocs === null, - }, - signal, - ) + .answerStream(payload, signal) .then((response) => { if (!response.body) throw Error('No response body'); @@ -169,20 +161,13 @@ export function handleSearch( conversation_id: conversation_id, chunks: chunks, token_limit: token_limit, + isNoneDoc: selectedDocs === null, }; if (selectedDocs && 'id' in selectedDocs) payload.active_docs = selectedDocs.id as string; payload.retriever = selectedDocs?.retriever as string; return conversationService - .search({ - question: question, - active_docs: selectedDocs?.id as string, - conversation_id, - history, - chunks: chunks, - token_limit: token_limit, - isNoneDoc: selectedDocs === null, - }) + .search(payload) .then((response) => response.json()) .then((data) => { return data; diff --git a/frontend/src/conversation/conversationModels.ts b/frontend/src/conversation/conversationModels.ts index bf86678b..99bb69e6 100644 --- a/frontend/src/conversation/conversationModels.ts +++ b/frontend/src/conversation/conversationModels.ts @@ -40,4 +40,5 @@ export interface RetrievalPayload { prompt_id?: string | null; chunks: string; token_limit: number; + isNoneDoc: boolean; }