-
Notifications
You must be signed in to change notification settings - Fork 679
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
feat: python interpreter #182
Conversation
The example in hugging_face_tool.py has been run successfully. |
Thanks, @dandansamax. Looks amazing. I will look into it soon! |
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.
Overall looks cool. Please let us know if it is an original code or it was borrowed from somewhere.
self.state = self.action_space.copy() | ||
self.fuzz_state = {} | ||
|
||
def _execute_ast(self, expression: ast.AST) -> Any: |
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.
Is this whole file taken from somewhere?
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.
The logic of this class was borrowed from hugging face agent. See python_interpreter.py. However, most of the codes are rewritten to fit our need.
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.
@lightaime I think we should refer the original file since it is quite similar
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.
Sorry, I'm not very familiar with these licenses and copyright things. As Apache 2.0 request, I should contain original license from HuggingFace team and add our modifications copyright. However, the license checker didn't allow me to do that. Also, I don't know if it is acceptable in our project.
Another solution may be to totally modify its implementation. What do you think?
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.
Sure, we should add the link to the original hugging face implementation and their license to the docstring of PythonInterpreter
, and mention that it is adapted from the hugging face implementation. We should also mention what is added and rewritten.
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.
Thank you for your advisions. I have updated the docstring.
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.
Awesome! Liked it. Left some comments. As we mention, we may also support other actions like file IO. But it is not in the scope of this PR. But we may support unsafe running mode or safe running mode with docker in the future. Thanks!
self.state = self.action_space.copy() | ||
self.fuzz_state = {} | ||
|
||
def _execute_ast(self, expression: ast.AST) -> Any: |
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.
Sure, we should add the link to the original hugging face implementation and their license to the docstring of PythonInterpreter
, and mention that it is adapted from the hugging face implementation. We should also mention what is added and rewritten.
camel/utils/python_interpreter.py
Outdated
Returns: | ||
Any: An evaluation value of the last line in the code. | ||
""" | ||
if state: |
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.
if state: | |
if state is not None: |
Co-authored-by: Guohao Li <lightaime@gmail.com>
Co-authored-by: Guohao Li <lightaime@gmail.com>
Co-authored-by: Guohao Li <lightaime@gmail.com>
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.
Please resolve the remaining comment about the reference to the original code.
Updated. Could you please review it? |
Description
utils.py
as a individual modulecamel.utils
PythonInterpreter
class incamel.utils
, an abstraction controlable python code executor. It contains several features thaneval()
like variable accessing control, module import, and fuzzy variable matching. It is also extendable and flexiable.EmbodiedAgent
from built-in functioneval()
toPythonInterpreter
Motivation and Context
#150
Types of changes
What types of changes does your code introduce? Put an
x
in all the boxes that apply:Implemented Tasks
Checklist
Go over all the following points, and put an
x
in all the boxes that apply.If you are unsure about any of these, don't hesitate to ask. We are here to help!