A command-line AI assistant that lets you embed and chat with PDF documents using OpenAI embeddings, pgvector, and GPT-4.
- Parse and clean PDFs using PyMuPDF
- Generate OpenAI
text-embedding-3-smallvector embeddings - Store embeddings in PostgreSQL with
pgvector - Retrieve semantically similar pages using cosine similarity
- Chat with your PDF using GPT-4 (or GPT-4o), with streamed responses
- Interactive CLI with multi-document support
- Python 3.10+
- PostgreSQL with
pgvectorextension enabled - OpenAI API key
pip install -r requirements.txt
-
Create a PostgreSQL database
-
Install the
pgvectorextension:CREATE EXTENSION vector;
-
Configure your database connection in
app/core/postgres.py
Just run
docker compose upat the root folder.
POSTGRES_DB -> The database name to be created or used
POSTGRES_URL -> The database url, such as
localhost:5432
POSTGRES_USER -> Database user name
POSTGRES_PASSWORD -> Database password
OPENAI_KEY -> The API Key to be generated from OpenAI Dashboard
python main.py embed path/to/file.pdf
python main.py chat
You’ll be shown a list of available embedded PDFs to choose from. Once selected, type your questions and get AI-powered answers based on document context.
- PDF Parsing → Clean each page with
PyMuPDF - Embedding → Use OpenAI to embed each page’s content
- Storage → Insert into PostgreSQL with
pgvector - Retrieval → Find top-N most relevant pages via cosine similarity
- Prompt Assembly → Inject pages as context + user prompt
- Response → Stream answers from OpenAI GPT-4o
MIT — use freely, attribute if you build on it.
Umut Cevdet Koçak
Built as a weekend project to explore vector search, embeddings, and conversational RAG systems.