A Streamlit-powered chatbot that answers questions about concerts using LangChain and SerpAPI, with Ollama model support.
- Natural language Q&A about events
- Ollama LLM integration
- Real-time concert information via SerpAPI
The Concert Chatbot is a web app that answers questions about concerts using Retrieval-Augmented Generation (RAG). Built with LangChain, Ollama, Streamlit, and SerpAPI, it processes concert documents and fetches real-time event data. For a detailed look at the code and explanations, see the Jupyter Notebook: notebooks/app_description.ipynb.
-
Setup
Installed dependencies like Streamlit (web interface), LangChain (RAG pipelines), langchain-ollama/langchain-chroma (model and vector storage), and SerpAPI (event data). -
Model Configuration
Used Ollama to set up:- nomic-embed-text: Creates vector embeddings for text.
- llama3.1:8b: Generates summaries and responses with strict grounding.
-
Document Processing\
- Validated concert documents with
is_concert_relatedusing keywords (e.g., "concert"). - Summarized valid documents with the LLM and
ChatPromptTemplate. - Split summaries into chunks (
RecursiveCharacterTextSplitter) and stored vectors in Chroma.
- Validated concert documents with
-
Event Retrieval
Used SerpAPI (get_events_for_artist) to fetch and summarize up to three concert events, stored in Chroma. -
RAG Pipeline\
- Configured a Chroma retriever to fetch top 5 relevant chunks.
- Used
create_history_aware_retrieverfor context-aware retrieval. - Combined retrieval and LLM with
create_retrieval_chainfor conversational answers.
-
Streamlit Interface\
- Sidebar: Upload documents or search events.
- Chat Interface: Ask questions, view responses, and conversation history (
st.session_state). - Added error handling for empty inputs.
Explore details in notebooks/app_description.ipynb.
- Clone the repository:
git clone https://github.com/tSopermon/ProvectusInternship_NikolaosTsopanidis.git cd ProvectusInternship_NikolaosTsopanidis - Set up a virtual environment:
python -m venv venv source venv/bin/activate # Linux/Mac venv\Scripts\activate # Windows
- Install dependencies:
pip install -r requirements.txt
- Configure environment variables:
echo "SERPAPI_API_KEY=your_key_here" > .env
Important: The Concert Chatbot relies on Ollama models for its core functionality. Specifically, it requires nomic-embed-text for embeddings and llama3.1:8b for answering and summarizing. Without these models, the app will not function as intended. Follow the steps below to install and set up Ollama:
- Install Ollama:
- Download and install Ollama from the official Ollama download page. Follow the instructions specific to your operating system.
- Pull the required models:
- Open a terminal and run the following commands to download the necessary models:
ollama pull nomic-embed-text ollama pull llama3.1:8b
- Start the Ollama server:
- Ensure the Ollama server is running by executing:
ollama serve
- Ensure your virtual environment is activated.
- Run the application:
streamlit run src/app.py
- Once the app is running, you can access it at
http://localhost:8501in your web browser.
-
Upload a Concert Document
- Use the sidebar's text box to enter a concert-related document.
- Press the "Upload" button to update the database and generate a summary of the document.
-
Ask Questions
- Once the document is uploaded, type your question about the document in the main input box.
- The app will provide accurate answers based on the uploaded content.
-
Explore Concert Information
- Search for upcoming concerts or events by entering an artist's name.
- Get real-time details like dates and locations using SerpAPI integration.
Feel free to open issues or pull requests to improve this project!
This project is licensed under the MIT License - see the LICENSE file for details.