jeevesagent.vectorstore.postgres

Postgres + pgvector vector store.

Production durable storage. Lazy import via asyncpg; install with pip install 'jeevesagent[vectorstore-postgres]' and ensure the vector extension is enabled on your database (CREATE EXTENSION IF NOT EXISTS vector).

Schema (auto-created via init_schema()):

CREATE TABLE jeeves_vectors (
    id          TEXT PRIMARY KEY,
    content     TEXT NOT NULL,
    metadata    JSONB,
    embedding   vector(N) NOT NULL
);
CREATE INDEX ON jeeves_vectors USING hnsw (embedding vector_cosine_ops);

Filter language: full Mongo-style operators translated to JSONB SQL. $eq / $ne / $gt / $gte / $lt / $lte / $in / $nin / $and / $or / $not / $exists are all supported.

Classes

PostgresVectorStore

Vector store backed by Postgres + pgvector.

Module Contents

class jeevesagent.vectorstore.postgres.PostgresVectorStore(embedder: jeevesagent.core.protocols.Embedder, *, dsn: str, table: str = 'jeeves_vectors', dimension: int | None = None)[source]

Vector store backed by Postgres + pgvector.

async add(chunks: list[jeevesagent.loader.base.Chunk], ids: list[str] | None = None) list[str][source]
async count() int[source]
async delete(ids: list[str]) None[source]
classmethod from_chunks(chunks: list[jeevesagent.loader.base.Chunk], *, embedder: jeevesagent.core.protocols.Embedder, ids: list[str] | None = None, dsn: str, table: str = 'jeeves_vectors', dimension: int | None = None) PostgresVectorStore[source]
Async:

One-shot: construct a PostgresVectorStore + add chunks.

classmethod from_texts(texts: list[str], *, embedder: jeevesagent.core.protocols.Embedder, metadatas: list[dict[str, Any]] | None = None, ids: list[str] | None = None, dsn: str, table: str = 'jeeves_vectors', dimension: int | None = None) PostgresVectorStore[source]
Async:

One-shot: construct a PostgresVectorStore from raw text strings (each becomes a Chunk with the matching metadata dict, or empty if metadatas is None).

async get_by_ids(ids: list[str]) list[jeevesagent.loader.base.Chunk][source]
async init_schema(dimension: int) None[source]

Create the table + HNSW index. Idempotent.

async search(query: str, *, k: int = 4, filter: collections.abc.Mapping[str, Any] | None = None, diversity: float | None = None) list[jeevesagent.vectorstore.base.SearchResult][source]
async search_by_vector(vector: list[float], *, k: int = 4, filter: collections.abc.Mapping[str, Any] | None = None, diversity: float | None = None) list[jeevesagent.vectorstore.base.SearchResult][source]
property embedder: jeevesagent.core.protocols.Embedder
name = 'postgres'