Chat with any PDF — Upload a PDF and ask questions about its content using Retrieval-Augmented Generation (RAG) with Langchain + ChromaDB + OpenAI.
🌐 Live Demo: https://chatpdf-moony.streamlit.app/
ChatPDF is a Streamlit web app that lets you upload any PDF and have a conversation with it. The app uses Langchain's retrieval pipeline — PDF text extraction, embedding, vector storage in ChromaDB, and answer generation via OpenAI GPT — so responses stay grounded in the actual document content.
- 📄 Drag-Drop Upload — Upload any text-based PDF
- 🔍 RAG Pipeline — Retrieves only the most relevant chunks before answering
- 💬 Multi-Turn Chat — Conversation memory within a session
- 🔒 Session-Scoped — PDFs are not persisted across sessions
- ⚡ Streaming Responses — Real-time token output
- 💸 Cost-Efficient — Selective token usage via retrieval
| Layer | Technology |
|---|---|
| Web Framework | Streamlit |
| PDF Parsing | PyPDF |
| Embeddings | OpenAI |
| Vector Database | ChromaDB |
| Retrieval Orchestration | Langchain |
| LLM | OpenAI GPT |
| Language | Python 3.9 |
PDF upload
↓
[PyPDF] Extract text → Split into chunks
↓
[OpenAI Embeddings] Vectorize chunks
↓
[ChromaDB] Store vectors + metadata
↓
User asks question
↓
[Embed query] → [Cosine similarity search] → Top-k chunks
↓
[OpenAI GPT] Answer using retrieved context
↓
Streamed response (with cited chunks)
- Python 3.9 (Download)
git clone https://github.com/moony01/chatpdf.git
cd chatpdf
pip install -r requirements.txt
# Add your OpenAI API key
echo "OPENAI_API_KEY=sk-..." > .env
streamlit run main.pyOpen the URL printed in the terminal (usually http://localhost:8501).
chatpdf/
├── main.py # Primary Streamlit app
├── main_streamit.py # Alternate Streamlit entry
├── requirements.txt # Python dependencies
├── unsu.pdf # Sample PDF for testing
└── .devcontainer/ # VSCode dev container config
MIT License © 2024–2026 moony01
You are free to use, modify, and distribute this code. Attribution appreciated.
- 👤 Author: @moony01
- 📧 Email: mun01180@gmail.com
- 🌐 Website: moony01.com
- 💖 Sponsor: github.com/sponsors/moony01