Streamlit is a faster way to build and share data apps. Streamlit turns data scripts into shareable web apps in minutes. All in pure Python. No front-end experience required. See more examples at streamlit.io/generative-ai.
StreamlitCallbackHandler
to display the thoughts and actions of an agent in an
interactive Streamlit app. Try it out with the running app below using the MRKL agent:
Installation and Setup
streamlit hello
to load a sample app and validate your install succeeded. See full instructions in Streamlit’s
Getting started documentation.
Display thoughts and actions
To create aStreamlitCallbackHandler
, you just need to provide a parent container to render the output.
Scenario 1: Using an Agent with Tools
The primary supported use case today is visualizing the actions of an Agent with Tools (or Agent Executor). You can create an agent in your Streamlit app and simply pass theStreamlitCallbackHandler
to agent.run()
in order to visualize the
thoughts and actions live in your app.
OPENAI_API_KEY
for the above app code to run successfully.
The easiest way to do this is via Streamlit secrets.toml,
or any other local ENV management tool.
Additional scenarios
CurrentlyStreamlitCallbackHandler
is geared towards use with a LangChain Agent Executor. Support for additional agent types,
use directly with Chains, etc will be added in the future.
You may also be interested in using
StreamlitChatMessageHistory for LangChain.