/StreamlitLangChain

Primary LanguagePythonApache License 2.0Apache-2.0

StreamlitLangChain

Repository for experimenting with Streamlit <> LangChain integrations. Current projects:

  • StreamlitCallbackHandler: Show LangChain agent steps and tool usage natively in Streamlit via LangChain Callbacks.
  • MRKL Demo: Demo the LangChain MRKL agent as a Streamlit app.

Setup

Create Python environment:

$ pipenv install
$ pipenv shell

Install pre-commit hook:

$ pre-commit install

Create .streamlit/secrets.toml:

openai_api_key = "[YOUR_KEY]"
serpapi_api_key = "[YOUR_KEY]"

Run

$ streamlit run mrkl_demo.py

Relevant Source Files

callbacks/

  • streamlit_callback_handler.py - LangChain callback handler that displays LangChain output in a Streamlit-y fashion
  • mutable_expander.py - used by the callback handler to create "dynamic" expander UIs
  • capturing_callback_handler.py - LangChain callback handler that captures and stores LangChain queries for offline replay. (This is a developer tool, and is not required by streamlit_callback_handler!)