Skip to content

Latest commit

Β 

History

History
116 lines (74 loc) Β· 2.61 KB

File metadata and controls

116 lines (74 loc) Β· 2.61 KB

πŸ“„ RAG Chat Application – Chat with Your PDF using GPT-4

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.


πŸš€ Features

  • 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

πŸ› οΈ Tech Stack

  • Frontend: Streamlit
  • LLM: OpenAI GPT-4.1
  • Embeddings: text-embedding-3-large from OpenAI
  • Vector DB: Qdrant
  • Chunking: LangChain's RecursiveCharacterTextSplitter

πŸ§‘β€πŸ’» Getting Started

1️⃣ Clone the Repository

git clone https://github.com/your-username/rag-chat-pdf.git
cd rag-chat-pdf

2️⃣ Set Up Your Environment

Install dependencies:

pip install -r requirements.txt

3️⃣ Add Your API Key

Create a .env file in the root directory:

OPENAI_API_KEY=sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

⚠️ Never hard-code your API key into the Python files.


4️⃣ Start Qdrant Locally

You can run Qdrant using Docker:

docker run -p 6333:6333 qdrant/qdrant

Make sure Qdrant is running before starting the app.


5️⃣ Launch the Streamlit App

streamlit run app.py

This will open the Streamlit app in your browser.


πŸ“ Project Structure

.
β”œβ”€β”€ 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

⚠️ Notes

  • 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.

βœ… To-Do (Optional Extensions)

  • Support multiple documents
  • Session-based chat memory
  • File-type support beyond PDFs (Word, Text, etc.)
  • Cloud-based deployment (Streamlit Cloud, HuggingFace Spaces)

πŸ™ Acknowledgements