Skip to content

Commit

Permalink
Merge pull request #1314 from Mayurakshi-mondal/issues/1313
Browse files Browse the repository at this point in the history
Fix: Pass retriever name to streaming api
  • Loading branch information
dartpain authored Oct 15, 2024
2 parents bcd9005 + 2779758 commit 2bf75c3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 24 deletions.
33 changes: 9 additions & 24 deletions frontend/src/conversation/conversationHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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<Answer>((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');

Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions frontend/src/conversation/conversationModels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,5 @@ export interface RetrievalPayload {
prompt_id?: string | null;
chunks: string;
token_limit: number;
isNoneDoc: boolean;
}

0 comments on commit 2bf75c3

Please sign in to comment.