A full-stack Retrieval-Augmented Generation (RAG) application that allows you to upload any PDF document and chat with it. It uses OpenAI's large language models and embeddings alongside a local Qdrant vector database to provide accurate, context-aware answers to your questions based on the document's contents.
- PDF Ingestion: Upload any PDF and automatically extract and chunk its text.
- Vector Search: Utilizes OpenAI's
text-embedding-3-largefor high-quality semantic embeddings and local Qdrant for fast similarity search. - Context-Aware Chat: Uses OpenAI's
gpt-4o-mini(or standard GPT models) to answer questions specifically using the provided document context. - Multi-turn Conversation: Maintains chat history for a seamless, continuous conversational experience.
- Streamlit UI: Clean and easy-to-use web interface.
- Frontend / UI: Streamlit
- LLM Orchestration: LangChain
- Embeddings & LLM: OpenAI API
- Vector Database: Qdrant (running via Docker)
- PDF Processing: PyPDFLoader
Before you begin, ensure you have the following installed:
- Python 3.9+
- Docker & Docker Compose (to run the Qdrant vector database locally)
- An OpenAI API Key
1. Clone the repository (if applicable) and navigate to the project directory:
cd Chatpdf-clone2. Set up a Python Virtual Environment (Recommended):
python -m venv env
# On Windows
env\Scripts\activate
# On macOS/Linux
source env/bin/activate3. Install dependencies:
pip install -r requirements.txt4. Configure Environment Variables:
Create a .env file in the root of the project and add your OpenAI API key:
OPENAI_API_KEY=your_openai_api_key_here5. Start the Qdrant Vector Database: Make sure Docker is running on your machine, then start the Qdrant container:
docker-compose up -d(This will run Qdrant in the background on port 6333)
Once everything is set up, start the Streamlit application:
streamlit run app.py- Open the provided local URL (usually
http://localhost:8501) in your browser. - Upload a PDF using the file uploader.
- Click the "📚 Prepare this PDF" button to process and index the document.
- Once indexing is complete, start asking questions in the chat box!
app.py: Main Streamlit application and UI logic.ingest.py: Handles PDF loading, text splitting, and embedding generation.query.py: Handles querying the vector database and generating LLM responses.docker-compose.yml: Configuration for running the local Qdrant instance.requirements.txt: Python dependencies.
- Qdrant Connection Error: Ensure Docker is running and you executed
docker-compose up -d. Check if port6333is occupied. - Missing API Key: Ensure your
.envfile is properly configured and located in the root directory.