klieo-memory-sqlite 3.8.2

SQLite-backed implementations of klieo-core's memory traits.
Documentation
//! Real fastembed-rs round-trip. Auto-downloads the model on first run
//! to the OS cache dir. Slow first invocation (~30s); subsequent runs
//! are fast.

#![cfg(all(feature = "fastembed", feature = "sqlite-vec"))]

use klieo_core::memory::{Fact, Scope};
use klieo_memory_sqlite::{FastEmbedEmbedder, MemorySqlite};
use std::sync::Arc;

#[tokio::test]
async fn fastembed_with_vec_round_trip() {
    let embedder = Arc::new(FastEmbedEmbedder::new().expect("fastembed init"));
    let mem = MemorySqlite::new(":memory:", embedder).await.unwrap();

    mem.long_term
        .remember(
            Scope::Global,
            Fact::new("the cat sat on the mat")
                .with_metadata(serde_json::json!({"source": "test"})),
        )
        .await
        .unwrap();
    mem.long_term
        .remember(Scope::Global, Fact::new("Rust async runtimes are great"))
        .await
        .unwrap();
    mem.long_term
        .remember(
            Scope::Global,
            Fact::new("octopuses are intelligent invertebrates"),
        )
        .await
        .unwrap();

    // Query semantically close to the cat-mat fact.
    let hits = mem
        .long_term
        .recall(Scope::Global, "where is the cat sitting?", 1)
        .await
        .unwrap();
    assert_eq!(hits.len(), 1);
    assert!(
        hits[0].text.contains("cat"),
        "expected cat-related fact for cat-related query, got: {}",
        hits[0].text
    );
}