GitHub - debezium/debezium-ai-python: A Python library to integrate Debezium with AI-enabled applications. Please log issues at https://github.com/debezium/dbz/issues. Resources
PyDebeziumAI is a Python library that streams row-level changes from Postgres through Debezium into a vector store like Chroma, PGVector, or Milvus, so LangChain and LangGraph retrieval stays current instead of depending on periodic batch reloads. It runs an embedded Debezium JVM, so it needs Java 17+.
- Captures every INSERT, UPDATE, and DELETE from the database write-ahead log and pushes it into the vector store as it happens, avoiding stale RAG results.
- Uses deterministic primary-key document IDs and idempotent upserts, so redelivered events after a restart don't create duplicates.
- Works offline with local sentence-transformers embeddings, with no API key required, and supports Chroma, PGVector, and Milvus backends.
- The README cites roughly 280–500ms total indexing time, though that figure depends on the embedding model and vector database.
PyDebeziumAI is a Python library that feeds database changes into a vector store so that a RAG pipeline never serves stale answers. Most RAG setups refresh their embeddings in periodic batch reloads, which means the index can lag behind the source table for hours. This project instead uses Debezium's change data capture to read the PostgreSQL write-ahead log and push every INSERT, UPDATE, and DELETE into the vector store as it happens. The example wires a `public.products` table through a `LiveContext` object, points it at Chroma with local sentence-transformers embeddings (so no API key is required), and exposes a LangChain retriever that can be dropped into any chain. The README claims end-to-end indexing latency of roughly 280 to 500 milliseconds, though that figure depends on the embedding model and vector database in use.
Setup has a few real requirements worth knowing before you try it. Java 17 or later must be installed, since the Debezium engine runs in an embedded JVM through the pydbzengine bridge, and you have to set JAVA_HOME per platform. You also need to run a setup script to download the Debezium engine JARs. Installation is driven by optional extras: `chroma`, `pgvector`, and `milvus` for backends, `local-embeddings` or `openai` for embeddings, `langgraph` for agent nodes, and `debezium` for the JVM bridge. On the reliability side, document IDs are deterministic and derived from primary keys, so replays after a restart are handled as idempotent upserts rather than duplicates. The library also includes exponential-backoff retries, a dead-letter queue, schema-evolution handling for additive and nullable column changes, and a "connect mode" that skips the JSON round-trip for lower latency.
The architecture is cleanly layered. Debezium events flow into an ingestion handler, a document builder applies a projection policy and computes IDs, and a sync manager handles upserts, deletes, and retries before writing through a vector store adapter. Backends are pluggable, and Chroma, PGVector, and Milvus are supported today, with more promised. The project is Apache 2.0 licensed, has full docs on Read the Docs, and points contributors to a CONVENTIONS.md file covering style, type checks, and DCO sign-off. What the README doesn't show is how it behaves under heavy write volume or large tables, so anyone planning production use should benchmark it against their own workload first.