upgrade multichoice questions

This commit is contained in:
Saifeddine ALOUI 2024-11-18 23:33:09 +01:00
parent a2097be6cf
commit adf292355d

View File

@ -437,7 +437,7 @@ class AIPersonality:
""" """
return self.multichoice_question(question, ["no","yes"], context, max_answer_length, conditionning=conditionning)>0 return self.multichoice_question(question, ["no","yes"], context, max_answer_length, conditionning=conditionning)>0
def multichoice_question(self, question: str, possible_answers:list, context:str = "", max_answer_length: int = 50, conditionning="") -> int: def multichoice_question(self, question: str, possible_answers:list, context:str = "", max_answer_length: int = 50, conditionning="", return_explanation=False) -> int:
""" """
Interprets a multi-choice question from a users response. This function expects only one choice as true. All other choices are considered false. If none are correct, returns -1. Interprets a multi-choice question from a users response. This function expects only one choice as true. All other choices are considered false. If none are correct, returns -1.
@ -479,7 +479,10 @@ class AIPersonality:
selection = gen.strip().split()[0].replace(",","").replace(".","") selection = gen.strip().split()[0].replace(",","").replace(".","")
self.print_prompt("Multi choice selection",prompt+gen) self.print_prompt("Multi choice selection",prompt+gen)
try: try:
return int(selection) if not return_explanation:
return int(selection)
else:
return int(selection), gen
except: except:
ASCIIColors.cyan("Model failed to answer the question") ASCIIColors.cyan("Model failed to answer the question")
return -1 return -1