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¶
Vector store backed by Postgres + |
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]¶
- 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
Chunkwith the matching metadata dict, or empty ifmetadatasis None).
- 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'¶