Skip to main content

Crate klieo_memory_pgvector

Crate klieo_memory_pgvector 

Source
Expand description

PostgreSQL + pgvector implementation of klieo_core::memory::LongTermMemory.

Sibling to klieo-memory-qdrant: the same LongTermMemory + FilterableLongTermMemory surface over an Aurora PostgreSQL Serverless v2 (or any Postgres with the vector extension) instead of Qdrant. Facts live in one table with a vector(dim) column (HNSW, cosine) and scope_kind / scope_value filter columns; metadata is stored as jsonb so relational joins to domain keys (Versicherungsnummer, Vertrag, GeVo-Typ) remain possible against the same table.

MemoryPgvector::connect(url) is the capability-shaped default — connects, lazily provisions the table on first remember, and returns an Arc<dyn LongTermMemory>. Defaults to DummyEmbedder.

§Quickstart

use klieo_memory_pgvector::MemoryPgvector;

async fn example() {
    let mem = MemoryPgvector::connect("postgres://localhost/klieo").await.unwrap();
    let _ = mem.long_term;
}

§Advanced wiring — custom config + embedder

use klieo_memory_pgvector::{MemoryPgvector, PgvectorConfig, DummyEmbedder};
use std::sync::Arc;

async fn example() {
    let cfg = PgvectorConfig::new("postgres://aurora.internal/klieo?sslmode=require")
        .with_table_prefix("triage")
        .with_embedder_id("titan-v2");
    let mem = MemoryPgvector::new(cfg, Arc::new(DummyEmbedder)).await.unwrap();
    let _ = mem.long_term;
}

§What’s implemented

Only LongTermMemory (+ FilterableLongTermMemory). ShortTermMemory and EpisodicMemory are not vector-shaped — see klieo-memory-sqlite / klieo-memory-neo4j.

Re-exports§

pub use client::PgvectorConfig;
pub use long_term::PgvectorLongTerm;
pub use factory::MemoryPgvector;

Modules§

client
PostgreSQL connection configuration + lazy table bootstrap.
embedder
Re-exports of the shared Embedder trait + dummy/fake impls.
error
Error mapping from sqlx errors to klieo_core::error::MemoryError.
factory
MemoryPgvector — convenience factory wrapping the LongTermMemory handle in an Arc<dyn …> ready for AgentContext.
long_term
PgvectorLongTermLongTermMemory over one Postgres table with a vector(dim) column (HNSW, cosine) and scope_kind / scope_value filter columns. Metadata is stored as jsonb.

Structs§

DummyEmbedder
Default embedder that returns zero vectors.
FakeEmbedder
Test-only embedder that hashes each input text into a deterministic vector. Identical texts produce identical embeddings, so cosine recall behaves predictably under test.

Traits§

Embedder
Compute embeddings for one or more texts.