Skip to main content

AutoMemory

Struct AutoMemory 

Source
pub struct AutoMemory {
    pub entries: Vec<MemoryEntry>,
    pub config: MemoryConfig,
    pub max_entries: usize,
    pub min_importance: f64,
    pub enabled: bool,
    /* private fields */
}
Expand description

Manager for automatic memory accumulation.

Fields§

§entries: Vec<MemoryEntry>

All memory entries.

§config: MemoryConfig

Configuration for memory management.

§max_entries: usize

Legacy fields for backward compatibility (deprecated).

§min_importance: f64§enabled: bool

Implementations§

Source§

impl AutoMemory

Source

pub fn new() -> Self

Create a new auto memory manager.

Source

pub fn rebuild_index(&mut self)

Rebuild search index.

Source

pub fn with_config(config: MemoryConfig) -> Self

Create with custom configuration.

Source

pub fn minimal() -> Self

Create a minimal memory manager.

Source

pub fn archival() -> Self

Create an archival memory manager.

Source

pub fn add(&mut self, entry: MemoryEntry)

Add a new memory entry.

Source

pub fn add_memory( &mut self, category: MemoryCategory, content: String, source_session: Option<String>, )

Add memory from detected content.

Source

pub fn has_similar(&self, content: &str) -> bool

Check if similar content already exists.

Source

pub fn calculate_similarity(a: &str, b: &str) -> f64

Calculate word-based similarity between two strings.

Source

pub fn prune(&mut self)

Remove low-importance entries when exceeding max_entries.

Source

pub fn smart_merge(&mut self) -> usize

Smart merge of similar memories.

Source

pub fn by_category(&self, category: MemoryCategory) -> Vec<&MemoryEntry>

Get entries by category.

Source

pub fn by_category_fast( &mut self, category: MemoryCategory, ) -> Vec<&MemoryEntry>

Get entries by category using index.

Source

pub fn top_n(&self, n: usize) -> Vec<&MemoryEntry>

Get top N most important entries.

Source

pub fn top_n_fast(&mut self, n: usize) -> Vec<&MemoryEntry>

Get top N using index.

Source

pub fn search(&self, query: &str) -> Vec<&MemoryEntry>

Search entries by content or tags.

Source

pub fn search_with_limit( &self, query: &str, limit: Option<usize>, ) -> Vec<&MemoryEntry>

Search entries with result limit.

Source

pub fn search_fast( &mut self, query: &str, limit: Option<usize>, ) -> Vec<&MemoryEntry>

Search using index.

Source

pub fn search_multi(&self, keywords: &[&str]) -> Vec<&MemoryEntry>

Multi-keyword search.

Source

pub fn search_multi_fast(&mut self, keywords: &[&str]) -> Vec<&MemoryEntry>

Multi-keyword search using index.

Source

pub fn add_batch(&mut self, entries: Vec<MemoryEntry>)

Batch add multiple entries.

Source

pub fn update_references(&mut self, messages: &[Message])

Mark entries as referenced.

Source

pub fn generate_prompt_summary(&self, max_entries: usize) -> String

Generate summary for system prompt.

Source

pub fn generate_contextual_summary( &self, context: &str, max_entries: usize, ) -> String

Generate context-aware summary.

Source

pub fn generate_contextual_summary_with_keywords( &self, context_keywords: &[String], max_entries: usize, ) -> String

Generate context-aware summary with pre-extracted keywords.

Source

pub fn update_retrieval_stats(&mut self, retrieved_ids: &[String])

Update reference statistics.

Source

pub fn get_retrieval_ids( &self, context_keywords: &[String], max_entries: usize, ) -> Vec<String>

Get IDs of entries for retrieval.

Source

pub async fn generate_contextual_summary_async( &self, context: &str, max_entries: usize, fast_provider: Option<&dyn Provider>, ) -> String

Generate context-aware summary async with AI keyword extraction.

Source

pub fn format_all(&self) -> String

Format all entries for display.

Source

pub fn generate_statistics(&self) -> MemoryStatistics

Generate statistics summary.

Source

pub fn clear(&mut self)

Clear all memories.

Source

pub fn remove(&mut self, id: &str) -> bool

Remove a specific memory by ID.

Source

pub fn apply_time_decay(&mut self)

Apply time decay to memory importance.

Trait Implementations§

Source§

impl Clone for AutoMemory

Source§

fn clone(&self) -> AutoMemory

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AutoMemory

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for AutoMemory

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for AutoMemory

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for AutoMemory

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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<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
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,