Skip to content

Commit b57eb57

Browse files
committed
Intial Commit
1 parent 6abf1a0 commit b57eb57

36 files changed

Lines changed: 676 additions & 0 deletions

README.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Django PDF Chat with Google Gemini (RAG)
2+
3+
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**.
4+
5+
## 🚀 Features
6+
7+
- **PDF Upload**: Easily upload and manage multiple PDF documents.
8+
- **RAG Architecture**: Uses LangChain to split, embed, and store document context for accurate AI responses.
9+
- **Google Gemini Integration**:
10+
- **Embeddings**: `models/gemini-embedding-001`
11+
- **Chat LLM**: `models/gemini-flash-latest`
12+
- **Vector Store**: Local **FAISS** index for fast and efficient retrieval.
13+
- **Modern UI**: Sidebar for document selection and a real-time chat interface.
14+
15+
## 🛠️ Prerequisites
16+
17+
- Python 3.10 or higher
18+
- A Google Gemini API Key (get one at [aistudio.google.com](https://aistudio.google.com/))
19+
20+
## 📦 Installation & Setup
21+
22+
1. **Clone the repository** (or navigate to the project folder).
23+
24+
2. **Create and activate a virtual environment**:
25+
```bash
26+
python3 -m venv venv
27+
source venv/bin/activate
28+
```
29+
30+
3. **Install dependencies**:
31+
```bash
32+
pip install -r requirements.txt
33+
```
34+
35+
4. **Configure Environment Variables**:
36+
Create a `.env` file in the root directory (already initialized if you followed the setup):
37+
```env
38+
GOOGLE_API_KEY=your_actual_gemini_api_key_here
39+
```
40+
41+
5. **Run Migrations**:
42+
```bash
43+
python manage.py makemigrations
44+
python manage.py migrate
45+
```
46+
47+
6. **Start the server**:
48+
```bash
49+
python manage.py runserver
50+
```
51+
52+
7. **Access the app**:
53+
Open [http://127.0.0.1:8000](http://127.0.0.1:8000) in your browser.
54+
55+
## 📂 Project Structure
56+
57+
- `chat/`: Main Django app containing logic for PDF processing and chat.
58+
- `chat/utils.py`: Core LangChain RAG pipeline.
59+
- `vector_stores/`: Local storage for FAISS indices (ignored by git).
60+
- `media/pdfs/`: Uploaded PDF files (ignored by git).
61+
- `.env`: Stores sensitive API keys.
62+
63+
## 🔧 Troubleshooting
64+
65+
- **429 RESOURCE_EXHAUSTED**: You've hit the Google Gemini free tier rate limit. Wait 60 seconds and try again.
66+
- **404 NOT_FOUND**: This usually means the model name or API version is incorrect. The project is currently tuned to `models/gemini-flash-latest`.
67+
- **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.
68+
69+
## 📝 License
70+
MIT

chat/__init__.py

Whitespace-only changes.
157 Bytes
Binary file not shown.
201 Bytes
Binary file not shown.
456 Bytes
Binary file not shown.
761 Bytes
Binary file not shown.
1.21 KB
Binary file not shown.
488 Bytes
Binary file not shown.
3.28 KB
Binary file not shown.
4.04 KB
Binary file not shown.

0 commit comments

Comments
 (0)