Skip to content

About

Upload a PDF and ask questions about its contents in a Streamlit chat app powered by OpenAI, LangChain, and Qdrant.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

ChatPDF Clone

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.

Features

  • PDF Ingestion: Upload any PDF and automatically extract and chunk its text.
  • Vector Search: Utilizes OpenAI's text-embedding-3-large for 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.

Tech Stack

Prerequisites

Before you begin, ensure you have the following installed:

  1. Python 3.9+
  2. Docker & Docker Compose (to run the Qdrant vector database locally)
  3. An OpenAI API Key

Setup & Installation

1. Clone the repository (if applicable) and navigate to the project directory:

cd Chatpdf-clone

2. Set up a Python Virtual Environment (Recommended):

python -m venv env
# On Windows
env\Scripts\activate
# On macOS/Linux
source env/bin/activate

3. Install dependencies:

pip install -r requirements.txt

4. 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_here

5. 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)

How to Run

Once everything is set up, start the Streamlit application:

streamlit run app.py
  1. Open the provided local URL (usually http://localhost:8501) in your browser.
  2. Upload a PDF using the file uploader.
  3. Click the "📚 Prepare this PDF" button to process and index the document.
  4. Once indexing is complete, start asking questions in the chat box!

Project Structure

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

Troubleshooting

  • Qdrant Connection Error: Ensure Docker is running and you executed docker-compose up -d. Check if port 6333 is occupied.
  • Missing API Key: Ensure your .env file is properly configured and located in the root directory.

About

Upload a PDF and ask questions about its contents in a Streamlit chat app powered by OpenAI, LangChain, and Qdrant.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages