Skip to content

markykim/Kindle-Vector-DB

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kindle Vector DB

📚 Import Kindle books into a vector database and ask questions about them using AI.

Features

  • Import books from text files or via Kindle Cloud Reader automation
  • Ask questions about your books using natural language
  • Interactive chat mode for conversational Q&A
  • Vector search powered by ChromaDB for fast, relevant retrieval
  • RAG-powered answers using OpenAI GPT-4o-mini

Quick Start

1. Install Dependencies

pip install -r requirements.txt

# For Kindle Cloud Reader automation, also install:
playwright install chromium

2. Set Up API Key

Copy .env.example to .env and add your OpenAI API key:

cp .env.example .env
# Edit .env and add your key

Get an API key from: https://platform.openai.com/api-keys

3. Import a Book

Option A: From a text file

python app.py import --file "path/to/book.txt" --title "Book Title"

Option B: From Kindle Cloud Reader (automated)

python app.py import --cloud-reader --title "Book Title"

4. Ask Questions

python app.py ask "Book Title" "What is the main theme of the book?"

5. Interactive Chat

python app.py chat "Book Title"

Commands

Command Description
import Import a book from file or Cloud Reader
ask Ask a single question about a book
chat Start an interactive chat session
list List all imported books
info Show info about a specific book
delete Remove a book from the database

How It Works

  1. Extract: Text is extracted from your Kindle book (via file upload or Cloud Reader automation)
  2. Chunk: Text is split into overlapping chunks for better context
  3. Embed: Each chunk is converted to a vector embedding using OpenAI
  4. Store: Embeddings are stored in ChromaDB for fast similarity search
  5. Query: Your questions are embedded and matched to relevant chunks
  6. Answer: GPT-4o-mini generates answers based on retrieved context (RAG)

Getting Book Text

Since Kindle books are DRM-protected, you have several options:

  1. Copy & Paste: Open the book in Kindle app, select text, and paste into a .txt file
  2. Kindle Cloud Reader: Use the --cloud-reader flag to automate extraction from read.amazon.com
  3. Notes & Highlights: Export your Kindle notes/highlights via Amazon

Costs

  • Embeddings: $0.00002 per 1000 tokens ($0.01 per 100 pages)
  • Q&A: ~$0.0001 per question using GPT-4o-mini

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages