Skip to main content

Crate mem7

Crate mem7 

Source
Expand description

§mem7

LLM-powered long-term memory engine with a Rust core and Python bindings.

§Quick start

use mem7::{MemoryEngine, MemoryEngineConfig, ChatMessage, MemoryFilter};

#[tokio::main]
async fn main() -> mem7::Result<()> {
    let config = MemoryEngineConfig::default();
    let engine = MemoryEngine::new(config).await?;

    let messages = vec![
        ChatMessage { role: "user".into(), content: "I love Rust".into(), images: vec![] },
    ];
    let result = engine.add(&messages, None, None, None, None, true).await?;
    println!("{result:?}");

    Ok(())
}

Modules§

dedup
Memory deduplication utilities.
embedding
Embedding client trait and the built-in implementations.
graph
Graph store trait and built-in implementations (FlatGraph, Kuzu, Neo4j).
history
Audit history trait and built-in SQLite implementation.
llm
LLM client trait and the built-in OpenAI-compatible implementation.
reranker
Reranker trait and built-in implementations (Cohere, LLM-based).
vector
Vector index trait and built-in implementations (in-process flat index, Upstash).

Structs§

AddOptions
Options for the MemoryEngine::add() method.
AddResult
Aggregated result of a full add() call.
ChatMessage
A chat message in the conversation.
EmbeddingConfig
Fact
A fact extracted by the LLM from a conversation.
GraphConfig
GraphRelation
A graph relation (subject-predicate-object triple).
HistoryConfig
LlmConfig
MemoryActionResult
Result of an add() operation for a single memory.
MemoryEngine
The core memory engine. Orchestrates the full add/search/get/update/delete/history pipeline.
MemoryEngineBuilder
Builder for MemoryEngine with dependency injection support.
MemoryEngineConfig
MemoryEvent
A single entry in the memory audit trail.
MemoryFilter
Filter criteria for querying memories.
MemoryItem
A single memory item stored in the system.
RerankerConfig
SearchOptions
Options for the MemoryEngine::search() method.
SearchResult
Result of a search() call.
TelemetryConfig
VectorConfig

Enums§

Mem7Error
MemoryAction
The type of memory event recorded in the audit trail.

Functions§

new_memory_id
Generate a new UUIDv7 memory ID (time-sortable, RFC 9562).

Type Aliases§

Result