pub struct CompactingMemory { /* private fields */ }Implementations§
Source§impl CompactingMemory
impl CompactingMemory
pub fn new( summarizer: Arc<dyn Summarizer>, config: CompactingMemoryConfig, ) -> CompactingMemory
pub fn with_default_config(summarizer: Arc<dyn Summarizer>) -> CompactingMemory
pub fn config(&self) -> &CompactingMemoryConfig
pub fn summary(&self) -> Option<String>
pub fn summarized_count(&self) -> usize
pub fn compression_history(&self) -> Vec<CompressionEvent>
Trait Implementations§
Source§impl Memory for CompactingMemory
impl Memory for CompactingMemory
Source§fn add_message<'life0, 'async_trait>(
&'life0 self,
message: ChatMessage,
) -> Pin<Box<dyn Future<Output = Result<(), AgentError>> + Send + 'async_trait>>where
'life0: 'async_trait,
CompactingMemory: 'async_trait,
fn add_message<'life0, 'async_trait>(
&'life0 self,
message: ChatMessage,
) -> Pin<Box<dyn Future<Output = Result<(), AgentError>> + Send + 'async_trait>>where
'life0: 'async_trait,
CompactingMemory: 'async_trait,
Append a message to conversation history.
Source§fn get_messages<'life0, 'async_trait>(
&'life0 self,
limit: Option<usize>,
) -> Pin<Box<dyn Future<Output = Result<Vec<ChatMessage>, AgentError>> + Send + 'async_trait>>where
'life0: 'async_trait,
CompactingMemory: 'async_trait,
fn get_messages<'life0, 'async_trait>(
&'life0 self,
limit: Option<usize>,
) -> Pin<Box<dyn Future<Output = Result<Vec<ChatMessage>, AgentError>> + Send + 'async_trait>>where
'life0: 'async_trait,
CompactingMemory: 'async_trait,
Get messages.
Some(n) returns the most recent N messages.Source§fn clear<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), AgentError>> + Send + 'async_trait>>where
'life0: 'async_trait,
CompactingMemory: 'async_trait,
fn clear<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), AgentError>> + Send + 'async_trait>>where
'life0: 'async_trait,
CompactingMemory: 'async_trait,
Remove all messages and reset state.
Source§fn snapshot<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<MemorySnapshot, AgentError>> + Send + 'async_trait>>where
'life0: 'async_trait,
CompactingMemory: 'async_trait,
fn snapshot<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<MemorySnapshot, AgentError>> + Send + 'async_trait>>where
'life0: 'async_trait,
CompactingMemory: 'async_trait,
Serialize current state for persistence.
Source§fn restore<'life0, 'async_trait>(
&'life0 self,
snapshot: MemorySnapshot,
) -> Pin<Box<dyn Future<Output = Result<(), AgentError>> + Send + 'async_trait>>where
'life0: 'async_trait,
CompactingMemory: 'async_trait,
fn restore<'life0, 'async_trait>(
&'life0 self,
snapshot: MemorySnapshot,
) -> Pin<Box<dyn Future<Output = Result<(), AgentError>> + Send + 'async_trait>>where
'life0: 'async_trait,
CompactingMemory: 'async_trait,
Restore from a previously saved snapshot, replacing current state.
Source§fn evict_oldest<'life0, 'async_trait>(
&'life0 self,
count: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<ChatMessage>, AgentError>> + Send + 'async_trait>>where
'life0: 'async_trait,
CompactingMemory: 'async_trait,
fn evict_oldest<'life0, 'async_trait>(
&'life0 self,
count: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<ChatMessage>, AgentError>> + Send + 'async_trait>>where
'life0: 'async_trait,
CompactingMemory: 'async_trait,
Remove the oldest N messages. Returns empty vec by default.
Source§impl Memory for CompactingMemory
impl Memory for CompactingMemory
fn get_context<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<ConversationContext, AgentError>> + Send + 'async_trait>>where
'life0: 'async_trait,
CompactingMemory: 'async_trait,
fn compress<'life0, 'life1, 'async_trait>(
&'life0 self,
summarizer: Option<&'life1 dyn Summarizer>,
) -> Pin<Box<dyn Future<Output = Result<CompressResult, AgentError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
CompactingMemory: 'async_trait,
fn needs_compression(&self) -> bool
Auto Trait Implementations§
impl !Freeze for CompactingMemory
impl !RefUnwindSafe for CompactingMemory
impl Send for CompactingMemory
impl Sync for CompactingMemory
impl Unpin for CompactingMemory
impl UnsafeUnpin for CompactingMemory
impl !UnwindSafe for CompactingMemory
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 moreCreates a shared type from an unshared type.