Template for a simple LLM chatbot using a Streamlit UI, and OpenAI or Mistral as a provider.
The chatbot is a quirky Santa Claus, which uses token streaming, random introductions, user feedback, and logging to phospho.
Demo: --> Click here to chat now with Santa Claus!
streamlit_app.py
: Streamlit user interface. Edit this to change the look and feel of the app.agent.py
: Chatbot logic and system prompts. Edit this to change the behaviour of the chatbot.
git clone git@github.com:phospho-app/template-chatbot-streamlit-openai.git
- Create a
secrets.toml
file in the.streamlit
folder.
OPENAI_API_KEY="xxx"
MISTRAL_API_KEY="xxx" # Optional, if you set provider to "mistral" in `main.py`
PHOSPHO_PROJECT_ID="xxx"
PHOSPHO_API_KEY="xxx"
- Install requirements. You need Python
>=3.9
# Optional: create a virtual env
python -m venv .env
# To activate the virtual env on MacOS and Linux:
source .env/bin/activate
# To activate the virtual env on Windows:
source .env/Scripts/activate
# Install requirements
pip install -r requirements.txt
- Run!
streamlit run streamlit_app.py
The easiest way to deploy the chatbot on internet is with Streamlit Community Cloud.
-
Fork this repository while connected to your github account. The Fork button is on the top right.
-
Login or register to Streamlit share with the same github account
-
On Streamlit share, click on "New App".
-
In the form, select your fork of the phospho repo. If you don't see the repo in the list, you can paste the URL.
-
In the main file path, enter
streamlit_app.py
- Click on Advanced Settings, and add the content of the
secrets.toml
file:
OPENAI_API_KEY="xxx"
PHOSPHO_PROJECT_ID="xxx"
PHOSPHO_API_KEY="xxx"
- Hit Save, and click deploy. Streamlit will now deploy your app on internet. Once it's done, click on the Share button on the top-right to share your Santa Claus chatbot.
Have a chat with your agent!
After talking to your agent, go to the phospho dashboard to see the logs.
Run a clustering or create custom analytics to detect specific patterns in conversations.
An issue? Special request? Feel free to reach out to contact@phospho.ai for technical questions, job opportunities, and anything else.