Skip to main content

MemoryEngine

Struct MemoryEngine 

Source
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

Source

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.

Source

pub async fn add_with_options( &self, messages: &[ChatMessage], opts: &AddOptions<'_>, ) -> Result<AddResult>

Add memories using structured options.

Source§

impl MemoryEngine

Source

pub async fn get(&self, memory_id: Uuid) -> Result<MemoryItem>

Source

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>>

Source

pub async fn update(&self, memory_id: Uuid, new_text: &str) -> Result<()>

Source

pub async fn delete(&self, memory_id: Uuid) -> Result<()>

Source

pub async fn delete_all( &self, user_id: Option<&str>, agent_id: Option<&str>, run_id: Option<&str>, ) -> Result<()>

Source

pub async fn history(&self, memory_id: Uuid) -> Result<Vec<MemoryEvent>>

Source

pub async fn reset(&self) -> Result<()>

Source§

impl MemoryEngine

Source

pub async fn new(config: MemoryEngineConfig) -> Result<Self>

Source§

impl MemoryEngine

Source

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.

Source

pub async fn search_with_options( &self, query: &str, opts: &SearchOptions<'_>, ) -> Result<SearchResult>

Search memories using structured options.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more