Skip to main content

Crate meme

Crate meme 

Source
Expand description

§meme

Long-term memory for AI agents.

meme is a production-grade memory pipeline written in Rust. It persists knowledge extracted from conversations (or raw facts) to disk via LanceDB and tracks every change in a SQLite audit log.

§Pipeline

  1. Semantic Structured Compression — dialogues are windowed and sent to an LLM which extracts atomic, self-contained Memory entries with structured metadata (timestamps, locations, persons, keywords, …).
  2. Lifecycle Reconciliation — each new entry is compared against existing memories in a single LLM call that decides ADD / UPDATE / DELETE / NOOP, preventing duplicates and resolving contradictions.
  3. Intent-Aware Hybrid Retrieval — queries are analyzed by an LLM to produce a retrieval plan that drives parallel semantic (ANN), lexical (FTS), and structured-metadata searches. Optional reflection rounds iteratively refine coverage.

§Quick Start

use meme::{Dialogue, Meme};

let meme = Meme::builder()
    .api_key("sk-...")
    .model("gpt-4.1-mini")
    .build()
    .await?;

// Ingest a conversation
meme.add(&[
    Dialogue::new("Alice", "Let's meet at 2pm tomorrow"),
    Dialogue::new("Bob", "Sure, see you at Shibuya station"),
]).await?;
meme.flush().await?;

// Store a fact directly (bypasses dialogue windowing)
meme.put("Alice prefers coffee over tea").await?;

// Hybrid search & Q&A
let memories = meme.search("Alice meeting").await?;
let answer  = meme.ask("When will Alice meet?").await?;

// CRUD
let all = meme.list().await?;
meme.update(all[0].id, "corrected content").await?;
meme.delete(all[0].id).await?;

// Audit trail
let events = meme.history(all[0].id).await?;

§Public API

Entry pointPurpose
MemeBuilderFluent builder — configure API key, model, storage path
MemeRuntime facade — add, flush, put, search, ask, CRUD, consolidate
MemoryA single self-contained unit of knowledge
DialogueSpeaker + content input for conversation ingestion
Event / EventTypeChange-history audit records
ConsolidationParamsParameters for Meme::consolidate
ConsolidationStatsSummary returned by Meme::consolidate

§Crate Layout

ModuleVisibilityContents
configpubPure data configuration structs with validation
errorpubMemeError enum and Result alias
modelpubDomain types (Memory, Dialogue, Event, …)
storepubLanceDB vector store, SQLite history store, consolidation
embeddingpub(crate)API and optional ONNX embedding providers
llmpub(crate)OpenAI-compatible LLM client, prompts, JSON schemas
pipelinepub(crate)Extractor, reconciler, hybrid retriever, answer generator

Re-exports§

pub use error::MemeError;
pub use model::Dialogue;
pub use model::Event;
pub use model::EventType;
pub use model::Memory;
pub use store::ConsolidationParams;
pub use store::ConsolidationStats;

Modules§

config
Configuration — pure data structures with defaults and validation.
error
Unified error types for the meme library.
model
Domain models — core data types for the memory system.
store
Storage layer — LanceDB vector store with multi-view indexing and SQLite history tracking.

Structs§

Meme
The main entry point for the meme memory system.
MemeBuilder
Fluent builder for constructing a Meme instance.