A Retrieval-Augmented Generation (RAG) chatbot that combines:
- 📂 Document ingestion (PDF, PPTX, DOCX, TXT, CSV, XLSX, images with OCR)
- 🧠 Embeddings & similarity search (using
sentence-transformers) - 🤖 LLM responses (via Google Gemini API)
- 🗄️ Hybrid database retrieval (SQLite + SQL Server)
- 🎧 Speech support (speech-to-text and text-to-speech with Gradio UI)
- Upload multiple document formats (PDF, PPTX, DOCX, TXT, CSV, Excel, images)
- Automatically extract text, chunk, embed, and store in SQLite
- Query knowledge base + SQL Server database simultaneously
- Generate answers using Google Gemini
- Gradio UI with:
- File management (upload/delete/ingest)
- Chat interface with memory
- On-demand audio playback of bot responses
- Voice input and TTS support
Clone the repository:
git clone https://github.com/ahmedayad0168/rag-chatbot.git
cd rag-chatbotCreate a virtual environment and activate it:
python -m venv venv
source venv/bin/activate # Linux/Mac
venv\Scripts\activate # WindowsInstall dependencies:
pip install -r requirements.txtCreate a .env file in the project root:
GEMINI_API_KEY=your_api_key_here
DB_PATH=DataBase.dbUpdate db_sqlserver.py with your SQL Server connection string if needed.
Run the Gradio interface:
python rag_ui.pyThis will open a local Gradio app in your browser where you can:
- Upload files
- Chat with the AI
- Play bot responses as audio
- Use voice input
rag-chatbot/
│── rag_ui.py # Gradio interface
│── main.py # Core RAG logic, Gemini, TTS, STT
│── ingest.py # Document parsing + embeddings + ingestion
│── database.py # SQLite storage (chunks + embeddings)
│── db_sqlserver.py # SQL Server queries
│── prompts.py # System prompt for Gemini
│── config.py # Config loader (dotenv)
│── .env # API keys & DB path (user-provided)
│── requirements.txt # Dependencies
gradiopython-dotenvsentence-transformersgoogle-generativeaipyttsx3speechrecognitionPyPDF2python-pptxpython-docxpandaspillowpytesseractpyodbcsqlite3(built-in)