From d839595330ac0be2356d1c2584016e7eae1c50eb Mon Sep 17 00:00:00 2001 From: Weves Date: Fri, 26 Jul 2024 17:31:34 -0700 Subject: [PATCH] Add query override --- backend/danswer/one_shot_answer/answer_question.py | 2 +- backend/danswer/one_shot_answer/models.py | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/backend/danswer/one_shot_answer/answer_question.py b/backend/danswer/one_shot_answer/answer_question.py index 54fe4a46f..96c6cd1fd 100644 --- a/backend/danswer/one_shot_answer/answer_question.py +++ b/backend/danswer/one_shot_answer/answer_question.py @@ -129,7 +129,7 @@ def stream_answer_objects( messages=history, max_tokens=max_history_tokens ) - rephrased_query = thread_based_query_rephrase( + rephrased_query = query_req.query_override or thread_based_query_rephrase( user_query=query_msg.message, history_str=history_str, ) diff --git a/backend/danswer/one_shot_answer/models.py b/backend/danswer/one_shot_answer/models.py index 0ed25b08a..d10986d21 100644 --- a/backend/danswer/one_shot_answer/models.py +++ b/backend/danswer/one_shot_answer/models.py @@ -34,10 +34,17 @@ class DirectQARequest(ChunkContext): skip_llm_chunk_filter: bool | None = None chain_of_thought: bool = False return_contexts: bool = False + + # allows the caller to specify the exact search query they want to use + # can be used if the message sent to the LLM / query should not be the same + # will also disable Thread-based Rewording if specified + query_override: str | None = None + # This is to toggle agentic evaluation: # 1. Evaluates whether each response is relevant or not # 2. Provides a summary of the document's relevance in the resulsts llm_doc_eval: bool = False + # If True, skips generative an AI response to the search query skip_gen_ai_answer_generation: bool = False