symfonic.memory.backends.postgres_vector¶
postgres_vector ¶
PostgreSQL vector backend using pgvector.
Implements VectorBackend protocol with cosine distance (<=> operator).
All operations enforce tenant isolation via WHERE tenant_id = $N.
asyncpg and pgvector must be installed.
pip install symfonic-core[postgres]
PostgresVectorBackend ¶
PostgresVectorBackend(pool: PostgresPoolManager, embedding_dim: int = 1536, *, search_strategy: Literal['exact', 'approximate'] = 'exact')
VectorBackend backed by PostgreSQL + pgvector.
Uses cosine distance (<=> operator) for similarity search.
All operations enforce tenant isolation via WHERE tenant_id = $N.
search_strategy='exact' ranks the authorized subset: bounded returned
rows, but O(visible vectors) database distance work. 'approximate' opts
into HNSW, which can underfill or miss neighbours after scope filtering.
Source code in src/symfonic/memory/backends/postgres_vector.py
pool
property
¶
The pool this backend speaks through, and so its transaction domain.
count
async
¶
Return the total number of stored vectors for the tenant.
Source code in src/symfonic/memory/backends/postgres_vector.py
ensure_schema
async
¶
Create the memory_vectors table and indexes if not present.