pub trait VectorMemory: Send + Sync {
// Required methods
fn store_text<'life0, 'async_trait>(
&'life0 self,
memory_id: String,
agent_id: String,
text: String,
metadata: Option<Value>,
) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn semantic_search<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
agent_id: &'life1 str,
query: &'life2 str,
limit: usize,
threshold: Option<f32>,
) -> Pin<Box<dyn Future<Output = Result<Vec<SearchResult>, String>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn clear<'life0, 'life1, 'async_trait>(
&'life0 self,
agent_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
}Expand description
High-level interface for semantic memory operations.
This trait combines embedding generation and vector storage to provide a complete semantic memory system. It handles the conversion of text memories into vector embeddings and provides semantic search capabilities.
Required Methods§
Sourcefn store_text<'life0, 'async_trait>(
&'life0 self,
memory_id: String,
agent_id: String,
text: String,
metadata: Option<Value>,
) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn store_text<'life0, 'async_trait>(
&'life0 self,
memory_id: String,
agent_id: String,
text: String,
metadata: Option<Value>,
) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Stores a text memory by generating its embedding and storing it.
§Arguments
memory_id- ID of the associated memory entryagent_id- ID of the agenttext- The text content to embed and storemetadata- Optional metadata to associate with the vector
Sourcefn semantic_search<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
agent_id: &'life1 str,
query: &'life2 str,
limit: usize,
threshold: Option<f32>,
) -> Pin<Box<dyn Future<Output = Result<Vec<SearchResult>, String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn semantic_search<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
agent_id: &'life1 str,
query: &'life2 str,
limit: usize,
threshold: Option<f32>,
) -> Pin<Box<dyn Future<Output = Result<Vec<SearchResult>, String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Searches for similar memories using semantic search.
§Arguments
agent_id- ID of the agent to search withinquery- The search query textlimit- Maximum number of resultsthreshold- Optional minimum similarity threshold