From dfda1437187fcea3a58f7be0187dc6976e4d25d7 Mon Sep 17 00:00:00 2001 From: Saifeddine ALOUI Date: Sat, 8 Feb 2025 03:03:49 +0100 Subject: [PATCH] enhanced yes no --- lollms/personality.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lollms/personality.py b/lollms/personality.py index e780a7b..b693e5e 100644 --- a/lollms/personality.py +++ b/lollms/personality.py @@ -489,18 +489,18 @@ class AIPersonality: - If return_explanation is False, returns a boolean (True for 'yes', False for 'no'). - If return_explanation is True, returns a dictionary with the answer and explanation. """ - prompt = f"{conditionning}\nQuestion: {question}\nContext: {context}\nAnswer strictly with 'yes' or 'no'. If explanation is needed, provide it in a separate field." + prompt = f"{conditionning}\nQuestion: {question}\nContext: {context}\n" template = """ { - "answer": "yes" | "no", + "answer": true | false, "explanation": "Optional explanation if return_explanation is True" } """ response = self.generate_code( prompt=prompt, - template=template if return_explanation else None, + template=template, language="json", code_tag_format="markdown", max_size=max_answer_length, @@ -515,9 +515,9 @@ class AIPersonality: explanation = parsed_response.get("explanation", "") if return_explanation: - return {"answer": answer == "yes", "explanation": explanation} + return {"answer": answer, "explanation": explanation} else: - return answer == "yes" + return answer except json.JSONDecodeError: return False