A simple and powerful Django-based web application that allows users to upload PDF documents and chat with their content using Retrieval-Augmented Generation (RAG). Powered by LangChain and Google Gemini AI.
- PDF Upload: Easily upload and manage multiple PDF documents.
- RAG Architecture: Uses LangChain to split, embed, and store document context for accurate AI responses.
- Google Gemini Integration:
- Embeddings:
models/gemini-embedding-001 - Chat LLM:
models/gemini-flash-latest
- Embeddings:
- Vector Store: Local FAISS index for fast and efficient retrieval.
- Modern UI: Sidebar for document selection and a real-time chat interface.
- Python 3.10 or higher
- A Google Gemini API Key (get one at aistudio.google.com)
-
Clone the repository (or navigate to the project folder).
-
Create and activate a virtual environment:
python3 -m venv venv source venv/bin/activate -
Install dependencies:
pip install -r requirements.txt
-
Configure Environment Variables: Create a
.envfile in the root directory (already initialized if you followed the setup):GOOGLE_API_KEY=your_actual_gemini_api_key_here
-
Run Migrations:
python manage.py makemigrations python manage.py migrate
-
Start the server:
python manage.py runserver
-
Access the app: Open http://127.0.0.1:8000 in your browser.
chat/: Main Django app containing logic for PDF processing and chat.chat/utils.py: Core LangChain RAG pipeline.vector_stores/: Local storage for FAISS indices (ignored by git).media/pdfs/: Uploaded PDF files (ignored by git)..env: Stores sensitive API keys.
- 429 RESOURCE_EXHAUSTED: You've hit the Google Gemini free tier rate limit. Wait 60 seconds and try again.
- 404 NOT_FOUND: This usually means the model name or API version is incorrect. The project is currently tuned to
models/gemini-flash-latest. - Vector store not found: Ensure the PDF status shows as "Completed" in the sidebar before chatting. If it says "Failed", check the server console for errors.
MIT