pub struct HierarchicalMemory<S: Summarizer> { /* private fields */ }Expand description
Hierarchical memory store with compaction
Implementations§
Source§impl<S: Summarizer> HierarchicalMemory<S>
impl<S: Summarizer> HierarchicalMemory<S>
Sourcepub fn new(config: MemoryCompactionConfig, summarizer: Arc<S>) -> Self
pub fn new(config: MemoryCompactionConfig, summarizer: Arc<S>) -> Self
Create a new hierarchical memory store
Sourcepub fn add_episode(&self, content: String, episode_type: EpisodeType) -> String
pub fn add_episode(&self, content: String, episode_type: EpisodeType) -> String
Add an episode to L0
Sourcepub fn add_episode_with_embedding(
&self,
content: String,
episode_type: EpisodeType,
embedding: Vec<f32>,
) -> String
pub fn add_episode_with_embedding( &self, content: String, episode_type: EpisodeType, embedding: Vec<f32>, ) -> String
Add episode with embedding
Sourcepub fn maybe_compact(&self) -> Result<bool, CompactionError>
pub fn maybe_compact(&self) -> Result<bool, CompactionError>
Check if compaction is needed and run if so
Sourcepub fn run_compaction(&self) -> Result<(), CompactionError>
pub fn run_compaction(&self) -> Result<(), CompactionError>
Run compaction cycle
Sourcepub fn total_tokens(&self) -> usize
pub fn total_tokens(&self) -> usize
Get total token count across all tiers
Sourcepub fn get_context(&self, max_tokens: usize) -> Vec<MemoryEntry>
pub fn get_context(&self, max_tokens: usize) -> Vec<MemoryEntry>
Get memory for context assembly (most recent first)
Sourcepub fn stats(&self) -> CompactionStats
pub fn stats(&self) -> CompactionStats
Get statistics
Sourcepub fn tier_counts(&self) -> (usize, usize, usize)
pub fn tier_counts(&self) -> (usize, usize, usize)
Get tier counts
Auto Trait Implementations§
impl<S> !Freeze for HierarchicalMemory<S>
impl<S> RefUnwindSafe for HierarchicalMemory<S>where
S: RefUnwindSafe,
impl<S> Send for HierarchicalMemory<S>
impl<S> Sync for HierarchicalMemory<S>
impl<S> Unpin for HierarchicalMemory<S>
impl<S> UnsafeUnpin for HierarchicalMemory<S>
impl<S> UnwindSafe for HierarchicalMemory<S>where
S: RefUnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more