This is a terminal-based prototype of a Retrieval-Augmented Generation (RAG) application.
It allows you to chat with a PDF document by leveraging a vector database (Qdrant) and Large Language Models (OpenAI).
- Document Ingestion – Loads a PDF, splits it into chunks, generates embeddings, and stores them in a Qdrant vector database.
- Interactive Chat – Provides a command-line interface to ask questions about the document.
- Dynamic Context Retrieval – Performs semantic search on the vector database to find the most relevant text chunks.
- AI-Powered Answers – Uses the retrieved context and the user’s question with an OpenAI model (e.g., GPT-4o) to generate contextual answers.
Make sure the following are installed on your local machine:
- Python 3.9+
- Docker & Docker Compose
- Git
Follow these steps to set up and run the project locally:
git clone https://github.com/Drexter-07/Prototype_PDF_Rag.gitIt's highly recommended to use a virtual environment to manage project dependencies.
python -m venv venv# On Windows:
.\venv\Scripts\activate
# On macOS/Linux:
source venv/bin/activateInstall all the required Python packages from the requirements.txt file.
pip install -r requirements.txtThis project requires an OpenAI API key.
Create a file named .env in the root of the project folder.
Add your API key to this file:
OPENAI_API_KEY="sk-YourSecretApiKeyGoesHere"The Qdrant vector database runs in a Docker container. Use the provided Docker Compose file to start it. The -d flag runs it in detached mode (in the background).
docker compose -f docker-compose.db.yml up -dYou can check if the container is running with docker ps.
Place the PDF file you want to chat with into the root of the project directory. The script is currently configured to look for a file named nodejs.pdf. You can change this in the RAG_Prototype.py script if you wish.
The application has two main phases: a one-time ingestion and the continuous chat loop.
The first time you run the script with a new PDF, you need to ingest its content into the database.
-
Uncomment the ingestion code block in RAG_Prototype.py.
-
Run the script:
python RAG_Prototype.pyWait for the "Ingestion Done" message.
Once finished, re-comment the ingestion block to avoid running it again unnecessarily.
With the ingestion complete, you can now run the script to start chatting with your document.
python RAG_Prototype.pyThe terminal will prompt you to ask questions. Type exit to quit the application.
🧹 Cleanup When you are finished, you can stop the Qdrant database container with the following command:
docker compose -f docker-compose.db.yml down