Open benjamin-manning opened 1 week ago
@benjamin-manning I've identified the issue: some results contain "None" answers. This can happen due to LLM response validation errors or exceeding the rate limit. In earlier versions, we had a repair loop to handle these issues, but we paused it since it led to too many API requests, which ironically caused the same problem it was trying to fix, like hitting the rate limit.
A temporary fix for the code will be to update the text_to_choice method to handle cases of None answers, for example:
def text_to_choice(txt):
d = {
"Allocate 70% to auto safety and 30% to highway safety": 70,
"Allocate 30% to auto safety and 70% to highway safety": 30,
"Allocate 60% to auto safety and 40% to highway safety": 60,
"Allocate 50% to auto safety and 50% to highway safety": 50,
}
if txt:
return d[txt]
return "None answer" #some default value you want.
ohhh got it, thanks! That makes sense - didn't realize it was a problem on my end.
Thank you @zer0dss !
I get this error when I run the attached code. Before it worked perfectly well
from edsl import AgentList, ModelList, ScenarioList, Study from edsl.questions import QuestionMultipleChoice
Construct agents
options_sets = [ ("car", "highway"), ("highway", "car"), ]
phrases = [ "{} safety is the most important thing.", "{} safety is a terrible waste of money; we should only fund {} safety.", "{} safety is all that mataters. We should not fund {} safety.", "{} safety and {} safety are equally important.", "{} safety is slightly more important than {} safety.", "I don't really care about {} safety or {} safety.", ]
views = [ phrase.format(option1, option2).capitalize() for option1, option2 in options_sets for phrase in phrases ]
def generate_answer(status_quo, auto): "Generates the answer text based on the status quo and the auto program share" if status_quo > auto: return f"Decrease auto program by {status_quo - auto}% of budget and raise the highway program by like amount" if status_quo == auto: return f"Maintain present budget amounts for the programs" if status_quo < auto: return f"Decrease the highway program by {auto - status_quo}% of budget and raise the auto program by like amount"
def choice_auto_frac(answer_text, status_quo_auto): "Returns the auto share of the choice based on the answer text and the status quo auto share" d = {} for possible_value in [70, 30, 60, 50]: d[(status_quo_auto, generate_answer(status_quo_auto, possible_value))] = ( possible_value ) return d[status_quo_auto, answer_text]
with Study( name="zeckhauser", filename="data/zeckhauser", description="Zeckhauser replication" ) as study: