langchain-ai / streamlit-agent

Reference implementations of several LangChain agents as Streamlit apps
Apache License 2.0
1.21k stars 608 forks source link

🦜️🔗 LangChain 🤝 Streamlit agent examples

Open in GitHub Codespaces

This repository contains reference implementations of various LangChain agents as Streamlit apps including:

Apps feature LangChain 🤝 Streamlit integrations such as the Callback integration and StreamlitChatMessageHistory.

More great app examples

Check out some other full examples of apps that utilize LangChain + Streamlit:

Setup

This project uses Poetry for dependency management.

# Create Python environment
$ poetry install

# Install git pre-commit hooks
$ poetry shell
$ pre-commit install

Running

# Run mrkl_demo.py or another app the same way
$ streamlit run streamlit_agent/mrkl_demo.py

Running with Docker

This project includes Dockerfile to run the app in Docker container. In order to optimise the Docker Image is optimised for size and building time with cache techniques.

To generate Image with DOCKER_BUILDKIT, follow below command

DOCKER_BUILDKIT=1 docker build --target=runtime . -t langchain-streamlit-agent:latest

  1. Run the docker container directly

docker run -d --name langchain-streamlit-agent -p 8051:8051 langchain-streamlit-agent:latest

  1. Run the docker container using docker-compose (Recommended)

Edit the Command in docker-compose with target streamlit app

docker-compose up

Contributing

We plan to add more agent and chain examples over time and improve the existing ones - PRs welcome! 🚀