This is a simple RAG (Retrieval-Augmented Generation) application built using Streamlit, LangChain, OpenAI, and Qdrant as the vector database. The app lets you upload a PDF file and chat with it, powered by GPT-4. It stores vectorized content from the PDF and retrieves relevant chunks to answer your questions.
- Upload any PDF
- PDF is split into chunks and stored as vector embeddings in Qdrant
- Ask questions about the PDF in natural language
- Get answers from GPT-4 based on the content of your uploaded PDF
- Frontend: Streamlit
- LLM: OpenAI GPT-4.1
- Embeddings:
text-embedding-3-largefrom OpenAI - Vector DB: Qdrant
- Chunking: LangChain's
RecursiveCharacterTextSplitter
git clone https://github.com/your-username/rag-chat-pdf.git
cd rag-chat-pdfInstall dependencies:
pip install -r requirements.txtCreate a .env file in the root directory:
OPENAI_API_KEY=sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
⚠️ Never hard-code your API key into the Python files.
You can run Qdrant using Docker:
docker run -p 6333:6333 qdrant/qdrantMake sure Qdrant is running before starting the app.
streamlit run app.pyThis will open the Streamlit app in your browser.
.
├── app.py # Streamlit app with Upload & Chat UI
├── .env # Your API key is stored here (DO NOT COMMIT)
├── requirements.txt # Python dependencies
└── README.md # Project documentation
- Only one PDF is processed at a time. If a new PDF is uploaded, the vector store is overwritten.
- GPT will answer only based on content from the uploaded PDF.
- You can expand this into a multi-document or session-based app using LangChain memory and persistent vector stores.
- Support multiple documents
- Session-based chat memory
- File-type support beyond PDFs (Word, Text, etc.)
- Cloud-based deployment (Streamlit Cloud, HuggingFace Spaces)