pub struct ConversationSummarizer { /* private fields */ }Expand description
Generates and caches conversation summaries for episodic memory.
Uses LLM to create concise summaries of conversation history. Implements incremental summarization - only new messages since the last summary are sent to the LLM, merged with the previous summary.
Implementations§
Source§impl ConversationSummarizer
impl ConversationSummarizer
Sourcepub fn with_threshold(self, n: usize) -> Self
pub fn with_threshold(self, n: usize) -> Self
Set the regeneration threshold (number of new messages before re-summarizing).
Sourcepub fn with_max_length(self, n: usize) -> Self
pub fn with_max_length(self, n: usize) -> Self
Set the maximum summary length in characters.
Sourcepub fn with_exclude_last(self, n: usize) -> Self
pub fn with_exclude_last(self, n: usize) -> Self
Set how many recent messages to exclude from summarization.
Sourcepub fn needs_regeneration(&self, current_message_count: usize) -> bool
pub fn needs_regeneration(&self, current_message_count: usize) -> bool
Check if summary needs regeneration based on message count delta.
Sourcepub fn get_cached_summary(&self) -> Option<&str>
pub fn get_cached_summary(&self) -> Option<&str>
Get cached summary if available.
Sourcepub fn generate_summary<F>(
&mut self,
messages: &[Value],
llm_caller: F,
) -> String
pub fn generate_summary<F>( &mut self, messages: &[Value], llm_caller: F, ) -> String
Generate summary of conversation history using incremental approach.
Only sends new messages since the last summary to the LLM, along with the previous summary for context merging.
The llm_caller receives a slice of message values (system + user prompt)
and should return Some(summary_text) on success.
Sourcepub fn format_conversation(messages: &[Value]) -> String
pub fn format_conversation(messages: &[Value]) -> String
Format messages into readable conversation text.
Sourcepub fn clear_cache(&mut self)
pub fn clear_cache(&mut self)
Clear the cached summary.