fixed multichoice questions

This commit is contained in:
Saifeddine ALOUI 2025-02-07 22:07:38 +01:00
parent 998bdd4015
commit 2d0473771c

View File

@ -479,7 +479,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="", return_explanation=False) -> int: def multichoice_question(self, question: str, possible_answers:list, context:str = "", max_answer_length: int = None, 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.
@ -540,10 +540,11 @@ class AIPersonality:
else: else:
return -1 return -1
except Exception as ex: except Exception as ex:
trace_exception(ex)
if return_explanation: if return_explanation:
return int(code.split('\n')[0]), "" return -1, ""
else: else:
return int(code.split('\n')[0]) return -1
def multichoice_ranking(self, question: str, possible_answers:list, context:str = "", max_answer_length: int = 50, conditionning="") -> int: def multichoice_ranking(self, question: str, possible_answers:list, context:str = "", max_answer_length: int = 50, conditionning="") -> int:
""" """
Ranks answers for a question from best to worst. returns a list of integers Ranks answers for a question from best to worst. returns a list of integers