pub struct CompactingMemory { /* private fields */ }Implementations§
Source§impl CompactingMemory
impl CompactingMemory
pub fn new( summarizer: Arc<dyn Summarizer>, config: CompactingMemoryConfig, ) -> Self
pub fn with_default_config(summarizer: Arc<dyn Summarizer>) -> Self
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<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn add_message<'life0, 'async_trait>(
&'life0 self,
message: ChatMessage,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: '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>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_messages<'life0, 'async_trait>(
&'life0 self,
limit: Option<usize>,
) -> Pin<Box<dyn Future<Output = Result<Vec<ChatMessage>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: '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<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn clear<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Remove all messages and reset state.
Source§fn snapshot<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<MemorySnapshot>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn snapshot<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<MemorySnapshot>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Serialize current state for persistence.
Source§fn restore<'life0, 'async_trait>(
&'life0 self,
snapshot: MemorySnapshot,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn restore<'life0, 'async_trait>(
&'life0 self,
snapshot: MemorySnapshot,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Restore from a previously saved snapshot, replacing current state.
Source§impl Memory for CompactingMemory
impl Memory for CompactingMemory
fn get_context<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<ConversationContext>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn compress<'life0, 'life1, 'async_trait>(
&'life0 self,
summarizer: Option<&'life1 dyn Summarizer>,
) -> Pin<Box<dyn Future<Output = Result<CompressResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: '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