pub struct SummarizeOlderStrategy { /* private fields */ }Expand description
Strategy that replaces older transcript items with a backend-generated summary.
The most recent keep_last removable items are kept verbatim. Everything
older (excluding items with a preserved ItemKind) is sent to the
configured CompactionBackend for summarisation. The summary items
replace the originals at their position in the transcript.
This strategy requires a backend. If CompactionContext::backend is
None, CompactionError::MissingBackend is returned.
§Example
use agentkit_compaction::SummarizeOlderStrategy;
use agentkit_core::ItemKind;
let strategy = SummarizeOlderStrategy::new(8)
.preserve_kind(ItemKind::System);Implementations§
Source§impl SummarizeOlderStrategy
impl SummarizeOlderStrategy
Sourcepub fn new(keep_last: usize) -> Self
pub fn new(keep_last: usize) -> Self
Create a strategy that keeps the last keep_last removable items and
summarises everything older.
Sourcepub fn preserve_kind(self, kind: ItemKind) -> Self
pub fn preserve_kind(self, kind: ItemKind) -> Self
Mark an ItemKind as preserved so that items of this kind are never
summarised, regardless of their position in the transcript.
Trait Implementations§
Source§impl Clone for SummarizeOlderStrategy
impl Clone for SummarizeOlderStrategy
Source§fn clone(&self) -> SummarizeOlderStrategy
fn clone(&self) -> SummarizeOlderStrategy
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl CompactionStrategy for SummarizeOlderStrategy
impl CompactionStrategy for SummarizeOlderStrategy
Source§fn apply<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
request: CompactionRequest,
ctx: &'life1 mut CompactionContext<'life2>,
) -> Pin<Box<dyn Future<Output = Result<CompactionResult, CompactionError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn apply<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
request: CompactionRequest,
ctx: &'life1 mut CompactionContext<'life2>,
) -> Pin<Box<dyn Future<Output = Result<CompactionResult, CompactionError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Apply this strategy to the transcript in
request. Read moreSource§impl Debug for SummarizeOlderStrategy
impl Debug for SummarizeOlderStrategy
Source§impl<'de> Deserialize<'de> for SummarizeOlderStrategy
impl<'de> Deserialize<'de> for SummarizeOlderStrategy
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for SummarizeOlderStrategy
impl PartialEq for SummarizeOlderStrategy
Source§impl Serialize for SummarizeOlderStrategy
impl Serialize for SummarizeOlderStrategy
impl Eq for SummarizeOlderStrategy
impl StructuralPartialEq for SummarizeOlderStrategy
Auto Trait Implementations§
impl Freeze for SummarizeOlderStrategy
impl RefUnwindSafe for SummarizeOlderStrategy
impl Send for SummarizeOlderStrategy
impl Sync for SummarizeOlderStrategy
impl Unpin for SummarizeOlderStrategy
impl UnsafeUnpin for SummarizeOlderStrategy
impl UnwindSafe for SummarizeOlderStrategy
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