pub struct WorkingMemory { /* private fields */ }Expand description
Working memory for managing recent context
Implementations§
Source§impl WorkingMemory
impl WorkingMemory
Sourcepub fn new(config: MemoryConfig) -> Self
pub fn new(config: MemoryConfig) -> Self
Create a new working memory instance
Sourcepub async fn add(&self, entry: EnhancedMemoryEntry) -> Result<(), String>
pub async fn add(&self, entry: EnhancedMemoryEntry) -> Result<(), String>
Add a memory to working memory
Sourcepub async fn get_all(&self) -> Vec<EnhancedMemoryEntry>
pub async fn get_all(&self) -> Vec<EnhancedMemoryEntry>
Get all working memories
Sourcepub async fn get_recent_within_limit(
&self,
max_tokens: usize,
) -> Vec<EnhancedMemoryEntry>
pub async fn get_recent_within_limit( &self, max_tokens: usize, ) -> Vec<EnhancedMemoryEntry>
Get recent memories up to a token limit
Sourcepub async fn get_by_importance(
&self,
min_importance: ImportanceLevel,
) -> Vec<EnhancedMemoryEntry>
pub async fn get_by_importance( &self, min_importance: ImportanceLevel, ) -> Vec<EnhancedMemoryEntry>
Get memories by importance level
Sourcepub async fn mark_accessed(&self, memory_id: &str) -> Result<(), String>
pub async fn mark_accessed(&self, memory_id: &str) -> Result<(), String>
Mark a memory as accessed (moves it to front)
Sourcepub async fn token_count(&self) -> usize
pub async fn token_count(&self) -> usize
Get current token count
Sourcepub async fn memory_count(&self) -> usize
pub async fn memory_count(&self) -> usize
Get current memory count
Sourcepub async fn create_context(&self, max_tokens: Option<usize>) -> String
pub async fn create_context(&self, max_tokens: Option<usize>) -> String
Create context message from working memory
Auto Trait Implementations§
impl Freeze for WorkingMemory
impl !RefUnwindSafe for WorkingMemory
impl Send for WorkingMemory
impl Sync for WorkingMemory
impl Unpin for WorkingMemory
impl !UnwindSafe for WorkingMemory
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