# Openverse's IIIT Kottayam Query Bot ![Openverse Logo](openverse2.svg) ## Overview Openverse's IIIT Kottayam Query Bot is an advanced, AI-powered chatbot designed to answer questions about IIIT Kottayam using a curated knowledge base. It features: - **Retrieval-Augmented Generation (RAG):** Answers are strictly based on a CSV knowledge base, ensuring factual and contextually relevant responses. - **Groq Model Rotation:** Automatically rotates between multiple Groq LLMs to avoid rate limits and maximize reliability. - **Admin Panel:** Allows admins to review and resolve unanswered questions, adding new knowledge to the database. - **Google Sheets Integration:** Unanswered questions are logged to a shared Google Sheet for collaborative review. - **Modern UI:** Streamlit-based interface with branding, watermark, and suggested question bubbles for a user-friendly experience. --- ## Features - **Strict Contextual Answers:** The bot only answers using the provided CSV context. If the answer is not found, it responds with a fallback phrase. - **Model Rotation:** Avoids Groq API rate limits by rotating models every 10 minutes. - **Admin Workflow:** Unanswered questions are logged to Google Sheets and can be resolved via the admin panel, which updates the CSV knowledge base. - **Branding:** Includes Openverse branding and a watermark image in the chat area. - **Suggested Questions:** Displays clickable question bubbles to help users get started. - **Vectorstore Inspector:** Inspect and test the FAISS vectorstore directly from the sidebar. --- ## Quickstart ### 1. Clone the Repository ```bash git clone cd RagBot ``` ### 2. Install Requirements ```bash pip install -r requirements.txt ``` ### 3. Environment Setup - Create a `.env` file with your Groq API key: ```env GROQ_API_KEY=your_groq_api_key_here ``` - Place your Google service account JSON (for Sheets logging) in the project root. - Share your Google Sheet with the service account email. ### 4. Prepare the Knowledge Base - Edit `data.csv` to add or update Q&A pairs. Format: `TOPIC,Question,answer` ### 5. Run the App ```bash streamlit run index.py ``` --- ## File Structure ``` RagBot/ ├── admin_panel.py # Streamlit admin panel for unresolved queries ├── data.csv # Main knowledge base (Q&A) ├── gsheet_logger.py # Google Sheets logging utility ├── index.py # Main Streamlit app ├── modules/ │ ├── chat.py # Chat UI and logic │ ├── chroma_inspector.py # Vectorstore inspector │ ├── llm.py # LLM chain and model rotation │ ├── pdf_handler.py # (Legacy) PDF support │ └── vectorstore.py # Vectorstore loading ├── requirements.txt # Python dependencies ├── openverse2.svg # Branding/logo └── ... ``` --- ## Google Sheets Integration - Unanswered questions are logged to a Google Sheet (see `gsheet_logger.py`). - The admin panel reads from this sheet and allows admins to resolve and add new answers to the CSV. - To set up: 1. Create a Google Sheet and share it with your service account email. 2. Update the Sheet ID in `gsheet_logger.py`. --- ## Customization - **Branding:** Replace `openverse2.svg` with your own logo if desired. - **Watermark:** The chat section displays a faded watermark image. - **Suggested Questions:** Edit or expand the list by updating `data.csv`. --- ## Troubleshooting - **OpenSSL/Cryptography Errors:** - If you see errors about OpenSSL legacy provider, set: ```bash export CRYPTOGRAPHY_OPENSSL_NO_LEGACY=1 ``` - **Google Sheets Logging Not Working:** - Ensure your service account JSON is correct and the sheet is shared with the service account email. - **Groq API Issues:** - Check your API key and model names in `.env` and `llm.py`. --- ## Credits - Built by Openverse for IIIT Kottayam. - Powered by Streamlit, Langchain, Groq, FAISS, and Google Sheets. --- ## License MIT License --- ## Contact For questions, suggestions, or contributions, open an issue or contact the Openverse team.