Skip to main content

marvin.memory.providers.postgres

Classes

PostgresMemory

An async MemoryProvider storing text + embeddings in PostgreSQL using SQLAlchemy + pg_vector, but with full async support. Methods:
  • add
    Insert a new record with an embedding vector. Returns the inserted record’s UUID.
  • configure
    1. Create an async engine.
    2. Optionally create the DB if it doesn’t exist (requires sync workaround).
    3. Install pgvector extension.
    4. Generate the memory table if missing.
    5. Initialize the async sessionmaker.
  • delete
    Delete a record by UUID.
  • search
    Async nearest-neighbor search via pgvector <-> operator or .l2_distance(), returning up to N results as {id: text}.

SQLMemoryTable

A simple declarative model that represents a memory record. We’ll dynamically set the tablename at runtime.
Parent Module: providers