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
- Semantic Structured Compression — dialogues are windowed and sent to
an LLM which extracts atomic, self-contained
Memoryentries with structured metadata (timestamps, locations, persons, keywords, …). - 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.
- 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 point | Purpose |
|---|---|
MemeBuilder | Fluent builder — configure API key, model, storage path |
Meme | Runtime facade — add, flush, put, search, ask, CRUD, consolidate |
Memory | A single self-contained unit of knowledge |
Dialogue | Speaker + content input for conversation ingestion |
Event / EventType | Change-history audit records |
ConsolidationParams | Parameters for Meme::consolidate |
ConsolidationStats | Summary returned by Meme::consolidate |
§Crate Layout
| Module | Visibility | Contents |
|---|---|---|
config | pub | Pure data configuration structs with validation |
error | pub | MemeError enum and Result alias |
model | pub | Domain types (Memory, Dialogue, Event, …) |
store | pub | LanceDB vector store, SQLite history store, consolidation |
embedding | pub(crate) | API and optional ONNX embedding providers |
llm | pub(crate) | OpenAI-compatible LLM client, prompts, JSON schemas |
pipeline | pub(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 —
LanceDBvector store with multi-view indexing andSQLitehistory tracking.
Structs§
- Meme
- The main entry point for the meme memory system.
- Meme
Builder - Fluent builder for constructing a
Memeinstance.