pub struct LlmCompactor { /* private fields */ }Expand description
Compaction strategies and managers for long conversations. 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)
Trait Implementations§
Source§impl Compactor for LlmCompactor
impl Compactor for LlmCompactor
Source§fn compact<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
messages: &'life1 [Message],
instruction: Option<&'life2 str>,
) -> Pin<Box<dyn Future<Output = Result<CompactedContext, CompactionError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn compact<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
messages: &'life1 [Message],
instruction: Option<&'life2 str>,
) -> Pin<Box<dyn Future<Output = Result<CompactedContext, CompactionError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
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 Freeze for LlmCompactor
impl !RefUnwindSafe for LlmCompactor
impl Send for LlmCompactor
impl Sync for LlmCompactor
impl Unpin for LlmCompactor
impl UnsafeUnpin for LlmCompactor
impl !UnwindSafe 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