Skip to content
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

Import of matplotlib.pyplot is not allowed. #291

Open
frederikhendrix opened this issue Jan 21, 2025 · 2 comments
Open

Import of matplotlib.pyplot is not allowed. #291

frederikhendrix opened this issue Jan 21, 2025 · 2 comments

Comments

@frederikhendrix
Copy link

It would be nice if you could add this import so the plot outputted can be saved as an image for example. This could turn the code Agent into a data visualisation Agent.

@albertvillanova
Copy link
Member

You can customize which libraries can be imported by passing additional_authorized_imports.

@touseefahmed96
Copy link

You can add which libraries can be imported in CodeAgent by passing the libraries to additional_authorized_imports

Example:

from smolagents import CodeAgent, HfApiModel

agent = CodeAgent(
    tools=[],
    model=HfApiModel(),
    additional_authorized_imports=["matplotlib"], # or any other you want 
)

agent_output = agent.run(
    "how to plot a graph in python"
)  

just make sure to first install matplotlib i-e pip install matplotlib

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants