mirror of
https://github.com/ParisNeo/lollms.git
synced 2025-02-28 20:05:51 +00:00
enhanced yes no
This commit is contained in:
parent
0dfe03fc7b
commit
dfda143718
@ -489,18 +489,18 @@ class AIPersonality:
|
|||||||
- If return_explanation is False, returns a boolean (True for 'yes', False for 'no').
|
- 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.
|
- 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 = """
|
template = """
|
||||||
{
|
{
|
||||||
"answer": "yes" | "no",
|
"answer": true | false,
|
||||||
"explanation": "Optional explanation if return_explanation is True"
|
"explanation": "Optional explanation if return_explanation is True"
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
response = self.generate_code(
|
response = self.generate_code(
|
||||||
prompt=prompt,
|
prompt=prompt,
|
||||||
template=template if return_explanation else None,
|
template=template,
|
||||||
language="json",
|
language="json",
|
||||||
code_tag_format="markdown",
|
code_tag_format="markdown",
|
||||||
max_size=max_answer_length,
|
max_size=max_answer_length,
|
||||||
@ -515,9 +515,9 @@ class AIPersonality:
|
|||||||
explanation = parsed_response.get("explanation", "")
|
explanation = parsed_response.get("explanation", "")
|
||||||
|
|
||||||
if return_explanation:
|
if return_explanation:
|
||||||
return {"answer": answer == "yes", "explanation": explanation}
|
return {"answer": answer, "explanation": explanation}
|
||||||
else:
|
else:
|
||||||
return answer == "yes"
|
return answer
|
||||||
except json.JSONDecodeError:
|
except json.JSONDecodeError:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user