pub struct ConversationSummaryBufferMemory { /* private fields */ }Expand description
Hybrid memory strategy: keeps recent messages verbatim and summarizes
older messages when total estimated tokens exceed max_token_limit.
Combines the benefits of ConversationSummaryMemory (compact history) with
ConversationTokenBufferMemory (recent context preserved exactly).
Implementations§
Source§impl ConversationSummaryBufferMemory
impl ConversationSummaryBufferMemory
Sourcepub fn new(
store: Arc<dyn MemoryStore>,
model: Arc<dyn ChatModel>,
max_token_limit: usize,
) -> Self
pub fn new( store: Arc<dyn MemoryStore>, model: Arc<dyn ChatModel>, max_token_limit: usize, ) -> Self
Create a new summary buffer memory.
store— the underlying message storemodel— the ChatModel used to generate summariesmax_token_limit— when total estimated tokens exceed this, older messages are summarized
Trait Implementations§
Source§impl MemoryStore for ConversationSummaryBufferMemory
impl MemoryStore for ConversationSummaryBufferMemory
fn append<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
message: Message,
) -> Pin<Box<dyn Future<Output = Result<(), SynapseError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn load<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<Message>, SynapseError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn clear<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), SynapseError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Auto Trait Implementations§
impl Freeze for ConversationSummaryBufferMemory
impl !RefUnwindSafe for ConversationSummaryBufferMemory
impl Send for ConversationSummaryBufferMemory
impl Sync for ConversationSummaryBufferMemory
impl Unpin for ConversationSummaryBufferMemory
impl UnsafeUnpin for ConversationSummaryBufferMemory
impl !UnwindSafe for ConversationSummaryBufferMemory
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