pub struct Memory<L: LLMProvider, E: EmbeddingProvider, S: StorageBackend, V: VectorBackend> { /* private fields */ }Expand description
Main interface for Umi memory system.
Orchestrates all components for a simple remember/recall API.
§Type Parameters
L: LLM provider for extraction, retrieval, evolution (SimLLMProvider for testing)S: Storage backend for persistence (SimStorageBackend for testing)
§Example
use umi_memory::umi::{Memory, RememberOptions, RecallOptions};
use umi_memory::{SimLLMProvider, SimStorageBackend, SimConfig};
let llm = SimLLMProvider::with_seed(42);
let embedder = SimEmbeddingProvider::with_seed(42);
let vector = SimVectorBackend::new(42);
let storage = SimStorageBackend::new(SimConfig::with_seed(42));
let mut memory = Memory::new(llm, embedder, vector, storage);
// Store and retrieve memories
memory.remember("Alice works at Acme", RememberOptions::default()).await?;
let results = memory.recall("Alice", RecallOptions::default()).await?;Implementations§
Source§impl<L: LLMProvider + Clone, E: EmbeddingProvider + Clone, S: StorageBackend + Clone, V: VectorBackend + Clone> Memory<L, E, S, V>
impl<L: LLMProvider + Clone, E: EmbeddingProvider + Clone, S: StorageBackend + Clone, V: VectorBackend + Clone> Memory<L, E, S, V>
Sourcepub fn new(llm: L, embedder: E, vector: V, storage: S) -> Self
pub fn new(llm: L, embedder: E, vector: V, storage: S) -> Self
Create a new Memory with all components.
§Arguments
llm- LLM provider (cloned for each component)embedder- Embedding provider (cloned for retriever)vector- Vector backend for similarity searchstorage- Storage backend (cloned for retriever)
Sourcepub fn builder() -> MemoryBuilder<L, E, V, S>
pub fn builder() -> MemoryBuilder<L, E, V, S>
Sourcepub async fn remember(
&mut self,
text: &str,
options: RememberOptions,
) -> Result<RememberResult, MemoryError>
pub async fn remember( &mut self, text: &str, options: RememberOptions, ) -> Result<RememberResult, MemoryError>
Store information in memory.
Extracts entities from text using LLM and stores them. Optionally detects evolution relationships with existing memories.
§Arguments
text- Text to rememberoptions- Remember options
§Returns
Ok(RememberResult) with stored entities and detected evolutions,
Err(MemoryError) for validation errors.
§Graceful Degradation
- If extraction fails, falls back to storing raw text as Note
- If evolution detection fails, skips without error
Sourcepub async fn recall(
&self,
query: &str,
options: RecallOptions,
) -> Result<Vec<Entity>, MemoryError>
pub async fn recall( &self, query: &str, options: RecallOptions, ) -> Result<Vec<Entity>, MemoryError>
Retrieve memories matching query.
Uses DualRetriever for smart search:
- Fast path: Direct search in storage
- Deep path: LLM rewrites query into variations, merges results
§Arguments
query- Search queryoptions- Recall options
§Returns
Ok(Vec<Entity>) with matching entities,
Err(MemoryError) for validation errors.
Sourcepub async fn count(&self) -> Result<usize, MemoryError>
pub async fn count(&self) -> Result<usize, MemoryError>
Count total entities in storage.
Source§impl Memory<SimLLMProvider, SimEmbeddingProvider, SimStorageBackend, SimVectorBackend>
impl Memory<SimLLMProvider, SimEmbeddingProvider, SimStorageBackend, SimVectorBackend>
Sourcepub fn sim(seed: u64) -> Self
pub fn sim(seed: u64) -> Self
Create a deterministic simulation Memory for testing.
All components (LLM, embedder, vector, storage) use the same seed for reproducible behavior.
TigerStyle: Convenient constructor for tests.
§Arguments
seed- Random seed for deterministic behavior
§Example
use umi_memory::umi::Memory;
let memory = Memory::sim(42);
// All operations will be deterministic with same seedSourcepub fn sim_with_config(_seed: u64, _config: MemoryConfig) -> Self
pub fn sim_with_config(_seed: u64, _config: MemoryConfig) -> Self
Create a deterministic simulation Memory with custom configuration.
Combines the convenience of sim() with custom config.
TigerStyle: Convenient constructor for configured tests.
§Arguments
seed- Random seed for deterministic behaviorconfig- Custom configuration
§Example
use umi_memory::umi::{Memory, MemoryConfig};
let config = MemoryConfig::default().with_recall_limit(5);
let memory = Memory::sim_with_config(42, config);