pub struct MemoryEngine { /* private fields */ }Expand description
The core memory engine. Orchestrates the full add/search/get/update/delete/history pipeline.
Implementations§
Source§impl MemoryEngine
impl MemoryEngine
Sourcepub async fn add(
&self,
messages: &[ChatMessage],
user_id: Option<&str>,
agent_id: Option<&str>,
run_id: Option<&str>,
metadata: Option<&Value>,
infer: bool,
) -> Result<AddResult>
pub async fn add( &self, messages: &[ChatMessage], user_id: Option<&str>, agent_id: Option<&str>, run_id: Option<&str>, metadata: Option<&Value>, infer: bool, ) -> Result<AddResult>
Add memories from a conversation.
When infer is true (the default), the LLM extracts facts from the
conversation, deduplicates them against existing memories, and decides
whether to add, update, or delete.
When infer is false, each message’s content is stored directly as a
new memory without any LLM processing — useful for importing raw text.
metadata is an optional JSON object stored under payload.metadata.
Sourcepub async fn add_with_options(
&self,
messages: &[ChatMessage],
opts: &AddOptions<'_>,
) -> Result<AddResult>
pub async fn add_with_options( &self, messages: &[ChatMessage], opts: &AddOptions<'_>, ) -> Result<AddResult>
Add memories using structured options.
Source§impl MemoryEngine
impl MemoryEngine
pub async fn get(&self, memory_id: Uuid) -> Result<MemoryItem>
pub async fn get_all( &self, user_id: Option<&str>, agent_id: Option<&str>, run_id: Option<&str>, filters: Option<&Value>, limit: Option<usize>, ) -> Result<Vec<MemoryItem>>
pub async fn update(&self, memory_id: Uuid, new_text: &str) -> Result<()>
pub async fn delete(&self, memory_id: Uuid) -> Result<()>
pub async fn delete_all( &self, user_id: Option<&str>, agent_id: Option<&str>, run_id: Option<&str>, ) -> Result<()>
pub async fn history(&self, memory_id: Uuid) -> Result<Vec<MemoryEvent>>
pub async fn reset(&self) -> Result<()>
Source§impl MemoryEngine
impl MemoryEngine
pub async fn new(config: MemoryEngineConfig) -> Result<Self>
Source§impl MemoryEngine
impl MemoryEngine
Sourcepub async fn search(
&self,
query: &str,
user_id: Option<&str>,
agent_id: Option<&str>,
run_id: Option<&str>,
limit: usize,
filters: Option<&Value>,
rerank: bool,
threshold: Option<f32>,
task_type: Option<&str>,
) -> Result<SearchResult>
pub async fn search( &self, query: &str, user_id: Option<&str>, agent_id: Option<&str>, run_id: Option<&str>, limit: usize, filters: Option<&Value>, rerank: bool, threshold: Option<f32>, task_type: Option<&str>, ) -> Result<SearchResult>
Search memories by semantic similarity.
filters is an optional JSON object evaluated against payload.metadata
using the filter DSL (simple equality, operators, AND/OR/NOT).
When a reranker is configured and rerank is true, the engine
over-fetches candidates by top_k_multiplier and then reranks them
down to limit.
Sourcepub async fn search_with_options(
&self,
query: &str,
opts: &SearchOptions<'_>,
) -> Result<SearchResult>
pub async fn search_with_options( &self, query: &str, opts: &SearchOptions<'_>, ) -> Result<SearchResult>
Search memories using structured options.