A lightweight AI system that lets you upload PDF files and ask questions about them in natural language using Mistral via OpenRouter API.
Screencast.from.2025-07-31.09-41-12.webm
- Backend: FastAPI, PyPDF2, SentenceTransformers, ChromaDB, OpenRouter (Mistral)
- Frontend: Next.js + Tailwind + Lucide Icons
- LLM: Mistral (via OpenRouter)
- Embedding Model:
all-MiniLM-L6-v2(via SentenceTransformers)
- 📤 Upload PDF
- ✂️ Extract and chunk text
- 🧠 Generate vector embeddings and store in ChromaDB
- 💬 Ask natural language questions
- 🤖 Answer generated using Mistral LLM with relevant chunks
- 🗑️ Clear/reset vector DB anytime
pip install fastapi uvicorn python-dotenv requests PyPDF2 \
sentence-transformers chromadbOPENROUTER_API_KEY=your_openrouter_key_here
uvicorn main:app --reloadPOST /upload_pdf/→ Upload and process PDFPOST /ask/→ Ask a question using MistralPOST /reset_all_db/→ Reset vector store
npx create-next-app@latest pdf-chat-ui
cd pdf-chat-ui
npm install lucide-reactHandles:
- PDF Upload
- API Calls
- Chat history UI
- Question box and reset logic
npm run devUse the following endpoint to delete all stored embeddings:
POST /reset_all_db/
- CORS middleware is enabled
- Embeddings are generated once per upload
- All conversations are stateless for now (no persistent memory)
- ChromaDB stores are automatically created and queried
# 1. Upload a PDF
curl -X POST http://localhost:8000/upload_pdf/ \
-F "file=@example.pdf"
# 2. Ask a question
curl -X POST http://localhost:8000/ask/ \
-F "query=What is the summary of this file?"- 🔁 Add chat memory
- 👥 Multi-user support
- 🌍 Multi-language translation
- 📊 PDF analytics and metrics