pub struct LlmCompactor { /* private fields */ }Expand description
LLM-based compactor that uses the model itself to summarize
Implementations§
Source§impl LlmCompactor
impl LlmCompactor
Sourcepub fn new(model: Model, provider: Arc<dyn Provider>) -> Self
pub fn new(model: Model, provider: Arc<dyn Provider>) -> Self
Create a new LLM compactor with default configuration
Sourcepub fn with_config(
model: Model,
provider: Arc<dyn Provider>,
config: CompactionConfig,
) -> Self
pub fn with_config( model: Model, provider: Arc<dyn Provider>, config: CompactionConfig, ) -> Self
Create a new LLM compactor with custom configuration
Sourcepub fn with_keep_recent(self, count: usize) -> Self
pub fn with_keep_recent(self, count: usize) -> Self
Set how many recent messages to always keep
Sourcepub fn with_max_batch(self, count: usize) -> Self
pub fn with_max_batch(self, count: usize) -> Self
Set maximum batch size for summarization
Sourcepub fn with_target_ratio(self, ratio: f32) -> Self
pub fn with_target_ratio(self, ratio: f32) -> Self
Set target compaction ratio
Source§impl LlmCompactor
Additional methods for LlmCompactor (not part of Compactor trait)
impl LlmCompactor
Additional methods for LlmCompactor (not part of Compactor trait)
Sourcepub async fn summarize_branch(
&self,
messages: &[Message],
branch_name: &str,
) -> Result<String, CompactionError>
pub async fn summarize_branch( &self, messages: &[Message], branch_name: &str, ) -> Result<String, CompactionError>
Summarize a conversation branch for comparison purposes.
This is used when branching occurs and you want to understand what changed compared to another branch (e.g., main).
Trait Implementations§
Source§impl Compactor for LlmCompactor
impl Compactor for LlmCompactor
Source§fn compact<'a>(
&'a self,
messages: &'a [Message],
instruction: Option<&'a str>,
) -> Pin<Box<dyn Future<Output = Result<CompactedContext, CompactionError>> + Send + 'a>>
fn compact<'a>( &'a self, messages: &'a [Message], instruction: Option<&'a str>, ) -> Pin<Box<dyn Future<Output = Result<CompactedContext, CompactionError>> + Send + 'a>>
Compact messages, returning a summary and kept messages
Source§fn estimate_tokens(&self, messages: &[Message]) -> usize
fn estimate_tokens(&self, messages: &[Message]) -> usize
Estimate the token count of messages
Auto Trait Implementations§
impl !RefUnwindSafe for LlmCompactor
impl !UnwindSafe for LlmCompactor
impl Freeze for LlmCompactor
impl Send for LlmCompactor
impl Sync for LlmCompactor
impl Unpin for LlmCompactor
impl UnsafeUnpin for LlmCompactor
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