From 07e03c6aad58fb1af977a7e5c676d6fc176a4f75 Mon Sep 17 00:00:00 2001 From: harshita-singh12 Date: Sat, 29 Aug 2026 17:55:33 +0000 Subject: [PATCH] fix(server): answer boolean questions per question, not per character /get_boolean_answer passed each question (a string) to AnswerPredictor.predict_boolean_answer, which iterates its input_question argument - so the NLI model was called once per CHARACTER, and the route then checked the returned list for truthiness. A non-empty question always produced a non-empty list, so the endpoint returned "True" for every question regardless of content. Pass the full question list once and map the returned booleans to the "True"/"False" strings the route contract promises. --- backend/server.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/backend/server.py b/backend/server.py index 683c1241..29986b85 100644 --- a/backend/server.py +++ b/backend/server.py @@ -226,19 +226,18 @@ def get_answer(): @app.route("/get_boolean_answer", methods=["POST"]) def get_boolean_answer(): + """POST /get_boolean_answer - returns "True"/"False" for each yes/no question via the NLI model.""" data = request.get_json() input_text = data.get("input_text", "") input_questions = data.get("input_question", []) - output = [] - for question in input_questions: - qa_response = answer.predict_boolean_answer( - {"input_text": input_text, "input_question": question} - ) - if(qa_response): - output.append("True") - else: - output.append("False") + # predict_boolean_answer expects the full list of questions; passing one + # question at a time made it iterate over the string's characters, and + # checking the returned (always non-empty) list made every answer "True". + answers = answer.predict_boolean_answer( + {"input_text": input_text, "input_question": input_questions} + ) + output = ["True" if answer else "False" for answer in answers] return jsonify({"output": output})