-
Notifications
You must be signed in to change notification settings - Fork 14
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
Optional argument support for smolagents #11
Optional argument support for smolagents #11
Conversation
@murawakimitsuhiro looks good to me at first glance I will pull it and test locally |
@murawakimitsuhiro just the lint complaining could you run ruff ? |
with regard to your comment:
In my view, case 3 is a positional argument which is not optional even though it might take None as a value so I agree. |
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.
looks good to me I would just add case 3 to the tests as well and run ruff to pass the lint
if text is None: | ||
return "No input provided" | ||
return f"Echo: {text}" | ||
|
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.
could we also add here the case 3? with text: str | None
@murawakimitsuhiro all good, great work thanks a lot! |
@grll Thank you very much for the swift reply! |
I just tested release 0.0.15 and it does solve my issue as well. Thank you to both! |
Fixes This PR resolves the error in issue #10 (related huggingface/smolagents#626 )
Error output
The fix addresses cases where arguments are provided using the
anyOf
schema.Changed
Implementation approach for optional and default arguments
I've addressed three scenarios related to issue.
text: str | None = None
text: str = "hello"
text: str | None
The current implementation outputs the following forward function for each case
For optional arguments without default values (case 3), I chose to maintain the existing implementation approach, requiring CodeAgent to explicitly specify these values rather than automatically providing None. But I'm open to discussion on this design choice.
Thank you for reviewing this PR!