mirror of
https://github.com/open-thought/reasoning-gym.git
synced 2026-04-28 17:29:39 +00:00
don't pass answer value to eval
This commit is contained in:
parent
2e9877ae07
commit
eaef88b45b
1 changed files with 3 additions and 3 deletions
|
|
@ -117,10 +117,10 @@ Please follow the instruction below:
|
||||||
try:
|
try:
|
||||||
# Try to parse the user's answer as a JSON list first
|
# Try to parse the user's answer as a JSON list first
|
||||||
try:
|
try:
|
||||||
|
answer = answer.replace("'", '"')
|
||||||
user_answer = json.loads(answer)
|
user_answer = json.loads(answer)
|
||||||
except json.JSONDecodeError:
|
except json.JSONDecodeError:
|
||||||
# If JSON parsing fails, fall back to eval (with caution)
|
return 0.0 # JSON parsing failed
|
||||||
user_answer = eval(answer)
|
|
||||||
|
|
||||||
if not isinstance(user_answer, list):
|
if not isinstance(user_answer, list):
|
||||||
return 0.0
|
return 0.0
|
||||||
|
|
@ -159,7 +159,7 @@ Please follow the instruction below:
|
||||||
return 0.0
|
return 0.0
|
||||||
|
|
||||||
return 1.0
|
return 1.0
|
||||||
except Exception as e:
|
except Exception:
|
||||||
# Any parsing error means the answer is incorrect
|
# Any parsing error means the answer is incorrect
|
||||||
return 0.0
|
return 0.0
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue