So I’m trying to create a multi agent LLM application using Langgraph and Streamlit. With Langgraph’s official jupyter notebook, the chart_generator agent is able to produce and execute python code using PythonREPL. The graphics/plot display correctly on JupyterNotebook but when I try to use st.write() and st.image() to display the graphics/plot, it’s not showing up. Would love to get some pointers if anyone has any idea.
If you’re creating a debugging post, please include the following info:
Are you running your app locally or is it deployed?
If your app is deployed:
a. Is it deployed on Community Cloud or another hosting platform?
b. Share the link to the public deployed app.
Share the link to your app’s public GitHub repository (including a requirements file).
Share the full text of the error message (not a screenshot).
If you can save the chart to file, you could use st.image() and you could also try one of several other methods mentioned in Chart elements - Streamlit Docs
Thanks for the speedy response.
But if you look into the code, the LLM agent is executing the Python code
@tool
def python_repl(
code: Annotated[str, "The python code to execute to generate your chart."],
):
"""Use this to execute python code. If you want to see the output of a value,
you should print it out with `print(...)`. This is visible to the user."""
try:
result = repl.run(code)
except BaseException as e:
return f"Failed to execute. Error: {repr(e)}"
result_str = f"Successfully executed:\n```python\n{code}\n```\nStdout: {result}"
return (
result_str + "\n\nIf you have completed all tasks, respond with FINAL ANSWER."
)```
Output in JupyterNotebook

I haven't been able to find a way to save the chart and not sure how JupyterNotebook is displaying it.
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.