How to display any kind of object with Streamlit

Hi All
I am trying to display a combination of text, figures and plots on the browser with streamlit at the same time (Please see attached examples). I have tried different methods but nothing is working. Your help is appreciated. Thanks.

Can you share sample code of what you’ve tried in Streamlit? Try to create an example dataframe inline with some simple data. Try to show what code you used to create a chart and display it in Streamlit.

A few sanity checks:

  1. In Streamlit, you will not use the same command to display charts that you use in Jupyter notebooks. For example, plt.show() is not going to do anything in Streamlit. For Streamlit, you need to pass your figure object to the correct display command.
    Chart elements - Streamlit Docs
  2. Make sure you are not trying to use Streamlit inside a Jupyter notebook. That’s not the intended use case out of the box.
  3. Here’s the documentation for displaying text, also.
    Text elements - Streamlit Docs

st.write is the most general command for rendering something on screen. You st.write('Any text hear') and you can st.write(figure_object).

The question is, what library exactly are you using to access OpenAI? Check the documentation for that library. Does agent.run() return an object? (e.g. if x = agent.run(), what is x?) What is the structure of that object? Can you access the data displayed in that returned “response” if it exists? If agent.run() does not return something and instead purely “prints” things through its execution, see if there is some other function (or additional parameters) that will give you some kind of response object.

I still don’t know off the top of my head which library you are using. This looks like an issue with whatever library you are using as an intermediary to OpenAI. Have you tried looking for a community or forum that is focused on that library? At this point, all I can do is Google search to forensically identify the packages you are using, then dig through their documentation to try and figure out what the pieces are.

Maybe someone here happens to know the library well and will respond, but I think you will get much faster help in an OpenAI-focused forum.

it is connecting to postgres database

Looks like you are passing one too many positional arguments to SQLDatabaseToolkit.

I don’t even know what a SQLDatabaseToolkit is. Hopefully there are examples and documentation out there.

Maybe not passing the argument? What made you think you should call it that way?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.