pub struct LlmContextCompactor<P: LlmProvider> { /* private fields */ }Expand description
LLM-based context compactor.
Uses the LLM itself to summarize older messages into a compact form.
Implementations§
Source§impl<P: LlmProvider> LlmContextCompactor<P>
impl<P: LlmProvider> LlmContextCompactor<P>
Sourcepub const fn new(provider: Arc<P>, config: CompactionConfig) -> Self
pub const fn new(provider: Arc<P>, config: CompactionConfig) -> Self
Create a new LLM context compactor.
Sourcepub fn with_defaults(provider: Arc<P>) -> Self
pub fn with_defaults(provider: Arc<P>) -> Self
Create with default configuration.
Sourcepub const fn config(&self) -> &CompactionConfig
pub const fn config(&self) -> &CompactionConfig
Get the configuration.
Trait Implementations§
Source§impl<P: LlmProvider> ContextCompactor for LlmContextCompactor<P>
impl<P: LlmProvider> ContextCompactor for LlmContextCompactor<P>
Source§fn compact<'life0, 'life1, 'async_trait>(
&'life0 self,
messages: &'life1 [Message],
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn compact<'life0, 'life1, 'async_trait>(
&'life0 self,
messages: &'life1 [Message],
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Compact a list of messages into a summary. Read more
Source§fn estimate_tokens(&self, messages: &[Message]) -> usize
fn estimate_tokens(&self, messages: &[Message]) -> usize
Estimate tokens for a message list.
Source§fn needs_compaction(&self, messages: &[Message]) -> bool
fn needs_compaction(&self, messages: &[Message]) -> bool
Check if compaction is needed.
Auto Trait Implementations§
impl<P> Freeze for LlmContextCompactor<P>
impl<P> RefUnwindSafe for LlmContextCompactor<P>where
P: RefUnwindSafe,
impl<P> Send for LlmContextCompactor<P>
impl<P> Sync for LlmContextCompactor<P>
impl<P> Unpin for LlmContextCompactor<P>
impl<P> UnwindSafe for LlmContextCompactor<P>where
P: RefUnwindSafe,
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