pub trait Compactor: Send + Sync {
// Required method
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;
// Provided method
fn estimate_tokens(&self, messages: &[Message]) -> usize { ... }
}Expand description
Compaction strategies and managers for long conversations. Trait for context compaction implementations
Required Methods§
Sourcefn 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
Provided Methods§
Sourcefn estimate_tokens(&self, messages: &[Message]) -> usize
fn estimate_tokens(&self, messages: &[Message]) -> usize
Estimate the token count of messages
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".