Skip to content

Conversation

@SyedAbdullahh
Copy link

Hi team,

This PR introduces a new Matplotlib Agent Toolkit to langchain_experimental/agents/agent_toolkits/matplotlib. It’s something I mentioned earlier in Issue #63 . The goal is to let LLMs generate Matplotlib visualizations directly from DataFrames through natural language.

What’s included

  • base.py: main logic for creating a Matplotlib-based agent
  • prompt.py: templates and example prompts
  • tests/test_matplotlib_toolkit.py: 7 unit tests (all passing)
  • README.md: usage guide, parameters, and security notes

What it does

The agent works with any LLM that supports tool-calling (like ChatOpenAI) and can handle one or multiple Pandas DataFrames.
It builds a custom prompt, uses PythonAstREPLTool for safe inline code execution, and returns an AgentExecutor that can turn natural language queries into plots.

Testing

You can run:

pytest  libs/experimental/tests/unit_tests/agents/agent_toolkits/matplotlib/test_matplotlib_toolkit.py -v

All tests pass locally — they cover agent creation, validation, error handling, and multiple DataFrame support.

Security

This agent uses a Python REPL, so allow_dangerous_code=True must be explicitly set by the user.
I’ve added clear warnings and notes in the README about sandboxing and safe environments.

@efriis, @ccurme

@SyedAbdullahh
Copy link
Author

@ccurme can you please review my pull request?

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

Successfully merging this pull request may close these issues.

1 participant