This repository contains a Streamlit-based chatbot application that leverages Ollama with Langchain library and integrates PostHog-LLM for analytics and monitoring.
- AI Chatbot: Uses Ollama with Langchain.
- Integration with PostHog-LLM: Enables detailed monitoring of chatbot interactions.
- Simple UI: Built with Streamlit for an easy-to-navigate user interface.
Clone this repository to your local machine:
git clone https://github.com/AndrMoura/streamlit-chatbot-analytics.git
cd streamlit-chatbot-analytics
Create a new virtual environment using venv
:
python -m venv venv
Activate the virtual environment:
For Windows:
venv\Scripts\activate
For macOS and Linux:
source venv/bin/activate
Install the necessary Python packages in requirements.txt:
pip install -r requirements.txt
Run the following command to install PostHog-LLM for monitoring:
sudo /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/postlang/posthog-llm/HEAD/bin/deploy-hobby)"
After a few minutes your PostHog-LLM instance will be available at https://localhost. Create your account and project grab your API key and export the following environment variables:
export POSTHOG_HOST='http://localhost'
export POSTHOG_API_KEY='UNDER_SETTINGS_PAGE'
Go to Ollama website and install for your OS. After installation, download the Llama3 8b model:
ollama run llama3
Run the application using Streamlit:
streamlit run streamlit/app.py
After starting the application, navigate to the provided local URL (http://localhost:8501) in your web browser to interact with the chatbot.
Check the PostHog-LLM instance in the activity page to monitor the chatbot interactions.