From 6d5340ae072f19954bb7feb47ff43ac36c603c08 Mon Sep 17 00:00:00 2001 From: Yuhong Sun <yuhongsun96@gmail.com> Date: Sat, 24 Feb 2024 14:01:59 -0800 Subject: [PATCH] Default Values (#1130) --- backend/danswer/one_shot_answer/answer_question.py | 3 +++ backend/danswer/one_shot_answer/models.py | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/backend/danswer/one_shot_answer/answer_question.py b/backend/danswer/one_shot_answer/answer_question.py index ff4f2cc00..535b19af0 100644 --- a/backend/danswer/one_shot_answer/answer_question.py +++ b/backend/danswer/one_shot_answer/answer_question.py @@ -120,6 +120,8 @@ def stream_answer_objects( user_query=query_msg.message, history_str=history_str, ) + # Given back ahead of the documents for latency reasons + # In chat flow it's given back along with the documents yield QueryRephrase(rephrased_query=rephrased_query) ( @@ -154,6 +156,7 @@ def stream_answer_objects( # Since this is in the one shot answer flow, we don't need to actually save the docs to DB initial_response = QADocsResponse( + rephrased_query=rephrased_query, top_documents=fake_saved_docs, predicted_flow=predicted_flow, predicted_search=predicted_search_type, diff --git a/backend/danswer/one_shot_answer/models.py b/backend/danswer/one_shot_answer/models.py index 6401b3440..71f14ff7f 100644 --- a/backend/danswer/one_shot_answer/models.py +++ b/backend/danswer/one_shot_answer/models.py @@ -1,6 +1,7 @@ from typing import Any from pydantic import BaseModel +from pydantic import Field from pydantic import root_validator from danswer.chat.models import DanswerContexts @@ -17,14 +18,14 @@ class QueryRephrase(BaseModel): class ThreadMessage(BaseModel): message: str sender: str | None - role: MessageType + role: MessageType = MessageType.USER class DirectQARequest(BaseModel): messages: list[ThreadMessage] prompt_id: int | None persona_id: int - retrieval_options: RetrievalDetails + retrieval_options: RetrievalDetails = Field(default_factory=RetrievalDetails) chain_of_thought: bool = False return_contexts: bool = False