-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix evaluate_condition for non-bool result #638
Fix evaluate_condition for non-bool result #638
Conversation
comparators = [ | ||
evaluate_ast(c, state, static_tools, custom_tools, authorized_imports) for c in condition.comparators | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moving the evaluate_ast
inside the loop, we avoid evaluating it for all condition.comparators
.
- Now, once a
current_result
is False, we return False
Thanks for cleaning this up @albertvillanova! I hadn't considered chained conditions in my PR, and I think your simplifications improve readability! |
Thank YOU, @kc9zyz. It was your PR which addressed the issue of non-bool results! Thanks again for your contribution. |
Fix evaluate_condition for non-bool result, as discussed in:
I think there are 2 bugs in
evaluate_condition
:.all()
method in:smolagents/src/smolagents/local_python_executor.py
Line 759 in b20da6a
.all
methodsmolagents/src/smolagents/local_python_executor.py
Lines 750 to 751 in cfe599c
pd.Series([1, 2, 3]) == pd.Series([2, 2, 2]) == pd.Series([3, 3, 3])
pd.Series([False, True, False]
ValueError("The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().")