Background worker for auto-generating vector embeddings. Uses graphile-worker to process embedding jobs triggered by Postgres INSERT/UPDATE triggers.
This is a private package -- not published to npm.
- When a record is inserted or updated in any embedding-enabled table (contacts, notes, companies, etc.), a Postgres trigger enqueues an
embed_recordjob viagraphile_worker.add_job() - The worker picks up the job, reads the record's source fields, and generates an embedding via Ollama (
nomic-embed-text) - The embedding vector is written back to the record's
embeddingcolumn - For tables with chunk support (contacts, notes), the worker also splits the text into chunks and embeds each chunk into the corresponding
*_chunkstable
# Start the worker (connects to the database and polls for jobs)
pnpm run start- A deployed
agentic-dbdatabase (see agentic-db) - Ollama running with the
nomic-embed-textmodel pulled (pgpm docker start --ollama, or your own instance) - Environment variables set (
eval "$(pgpm env)")
The worker reads table configurations from src/tasks/embed_record.ts, which defines:
- Which tables to embed
- Which fields to use as source text
- The Ollama model and endpoint
# Run tests
pnpm test
# Build
pnpm build