pub struct SummarizationTrimmer { /* private fields */ }Expand description
Summarization-based trimmer.
When context approaches the limit, uses a callback to summarize older messages into a compact form.
§Example
ⓘ
use bob_core::context_trimmer::{ContextTrimmer, SummarizationTrimmer};
let trimmer = SummarizationTrimmer::new(
100,
4096,
Arc::new(my_summarizer), // impl MessageSummarizer
);Implementations§
Source§impl SummarizationTrimmer
impl SummarizationTrimmer
Sourcepub fn new(
max_messages: usize,
target_tokens: usize,
summarizer: Arc<dyn MessageSummarizer>,
) -> Self
pub fn new( max_messages: usize, target_tokens: usize, summarizer: Arc<dyn MessageSummarizer>, ) -> Self
Create a new summarization trimmer.
Sourcepub fn with_config(
config: TrimConfig,
summarizer: Arc<dyn MessageSummarizer>,
) -> Self
pub fn with_config( config: TrimConfig, summarizer: Arc<dyn MessageSummarizer>, ) -> Self
Create with full configuration.
Trait Implementations§
Source§impl ContextTrimmer for SummarizationTrimmer
impl ContextTrimmer for SummarizationTrimmer
Source§fn trim<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
messages: &'life1 [Message],
_usage: &'life2 TokenUsage,
) -> Pin<Box<dyn Future<Output = Result<TrimResult, AgentError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn trim<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
messages: &'life1 [Message],
_usage: &'life2 TokenUsage,
) -> Pin<Box<dyn Future<Output = Result<TrimResult, AgentError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Trim the message history according to the strategy. Read more
Source§fn strategy_name(&self) -> &'static str
fn strategy_name(&self) -> &'static str
Human-readable name of this trimming strategy.
Auto Trait Implementations§
impl Freeze for SummarizationTrimmer
impl !RefUnwindSafe for SummarizationTrimmer
impl Send for SummarizationTrimmer
impl Sync for SummarizationTrimmer
impl Unpin for SummarizationTrimmer
impl UnsafeUnpin for SummarizationTrimmer
impl !UnwindSafe for SummarizationTrimmer
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