Skip to content

tSopermon/rag-concert-chatbot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Concert Chatbot

A Streamlit-powered chatbot that answers questions about concerts using LangChain and SerpAPI, with Ollama model support.

Streamlit App LangChain Ollama ChromaDB

Features

  • Natural language Q&A about events
  • Ollama LLM integration
  • Real-time concert information via SerpAPI

Development Process of the App

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.

  1. Setup
    Installed dependencies like Streamlit (web interface), LangChain (RAG pipelines), langchain-ollama/langchain-chroma (model and vector storage), and SerpAPI (event data).

  2. 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.
  3. Document Processing\

    • Validated concert documents with is_concert_related using keywords (e.g., "concert").
    • Summarized valid documents with the LLM and ChatPromptTemplate.
    • Split summaries into chunks (RecursiveCharacterTextSplitter) and stored vectors in Chroma.
  4. Event Retrieval
    Used SerpAPI (get_events_for_artist) to fetch and summarize up to three concert events, stored in Chroma.

  5. RAG Pipeline\

    • Configured a Chroma retriever to fetch top 5 relevant chunks.
    • Used create_history_aware_retriever for context-aware retrieval.
    • Combined retrieval and LLM with create_retrieval_chain for conversational answers.
  6. 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.

Installation

  1. Clone the repository:
    git clone https://github.com/tSopermon/ProvectusInternship_NikolaosTsopanidis.git
    cd ProvectusInternship_NikolaosTsopanidis
  2. Set up a virtual environment:
    python -m venv venv
    source venv/bin/activate  # Linux/Mac
    venv\Scripts\activate    # Windows
  3. Install dependencies:
    pip install -r requirements.txt
  4. Configure environment variables:
    echo "SERPAPI_API_KEY=your_key_here" > .env

Ollama Setup

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:

  1. Install Ollama:
  • Download and install Ollama from the official Ollama download page. Follow the instructions specific to your operating system.
  1. 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
  1. Start the Ollama server:
  • Ensure the Ollama server is running by executing:
    ollama serve

Running the App

  1. Ensure your virtual environment is activated.
  2. Run the application:
    streamlit run src/app.py
  3. Once the app is running, you can access it at http://localhost:8501 in your web browser.

How to Use the App

  1. 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.
  2. 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.
  3. 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.

Contributing

Feel free to open issues or pull requests to improve this project!

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

About

Web app that answers questions about concerts using Retrieval-Augmented Generation (RAG). Built with LangChain, Ollama, Streamlit, and SerpAPI, it processes uploaded concert documents and fetches real-time event data.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors