diff --git a/backend/onyx/agent_search/pro_search_a/answer_initial_sub_question/nodes/answer_check.py b/backend/onyx/agent_search/pro_search_a/answer_initial_sub_question/nodes/answer_check.py index 2d8e8c4d168..ac4ceb2ef7e 100644 --- a/backend/onyx/agent_search/pro_search_a/answer_initial_sub_question/nodes/answer_check.py +++ b/backend/onyx/agent_search/pro_search_a/answer_initial_sub_question/nodes/answer_check.py @@ -7,10 +7,16 @@ from onyx.agent_search.pro_search_a.answer_initial_sub_question.states import ( QACheckUpdate, ) +from onyx.agent_search.shared_graph_utils.prompts import SUB_CHECK_NO from onyx.agent_search.shared_graph_utils.prompts import SUB_CHECK_PROMPT +from onyx.agent_search.shared_graph_utils.prompts import UNKNOWN_ANSWER def answer_check(state: AnswerQuestionState) -> QACheckUpdate: + if state["answer"] == UNKNOWN_ANSWER: + return QACheckUpdate( + answer_quality=SUB_CHECK_NO, + ) msg = [ HumanMessage( content=SUB_CHECK_PROMPT.format( diff --git a/backend/onyx/agent_search/shared_graph_utils/prompts.py b/backend/onyx/agent_search/shared_graph_utils/prompts.py index 6ee3cbe21b3..18c8092ce00 100644 --- a/backend/onyx/agent_search/shared_graph_utils/prompts.py +++ b/backend/onyx/agent_search/shared_graph_utils/prompts.py @@ -79,8 +79,11 @@ """ ) +SUB_CHECK_YES = "yes" +SUB_CHECK_NO = "no" -SUB_CHECK_PROMPT = """ +SUB_CHECK_PROMPT = ( + """ Your task is to see whether a given answer addresses a given question. Please do not use any internal knowledge you may have - just focus on whether the answer as given seems to largely address the question as given, or at least addresses part of the question. @@ -92,7 +95,9 @@ \n ------- \n {base_answer} \n ------- \n - Does the suggested answer address the question? Please answer with yes or no:""" + Does the suggested answer address the question? Please answer with """ + + f'"{SUB_CHECK_YES}" or "{SUB_CHECK_NO}".' +) BASE_CHECK_PROMPT = """ \n