pub struct ToolResultCompactionStrategy { /* private fields */ }Expand description
SelectiveToolResult with a custom stand-in (upstream
ToolResultCompactionStrategy’s ToolCallFormatter): all but the last
keep_last tool results have their payload replaced by what the
formatter returns, keeping each exchange paired.
Implementations§
Source§impl ToolResultCompactionStrategy
impl ToolResultCompactionStrategy
Sourcepub fn new(keep_last: usize) -> ToolResultCompactionStrategy
pub fn new(keep_last: usize) -> ToolResultCompactionStrategy
Keep the last keep_last results verbatim; replace the rest with
[Tool results: <tool>] (upstream’s default label).
Sourcepub fn with_formatter(
self,
formatter: impl Fn(Option<&str>, &FunctionResultContent) -> String + Send + Sync + 'static,
) -> ToolResultCompactionStrategy
pub fn with_formatter( self, formatter: impl Fn(Option<&str>, &FunctionResultContent) -> String + Send + Sync + 'static, ) -> ToolResultCompactionStrategy
Format the stand-in with formatter.
Trait Implementations§
Source§impl Clone for ToolResultCompactionStrategy
impl Clone for ToolResultCompactionStrategy
Source§fn clone(&self) -> ToolResultCompactionStrategy
fn clone(&self) -> ToolResultCompactionStrategy
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for ToolResultCompactionStrategy
impl !UnwindSafe for ToolResultCompactionStrategy
impl Freeze for ToolResultCompactionStrategy
impl Send for ToolResultCompactionStrategy
impl Sync for ToolResultCompactionStrategy
impl Unpin for ToolResultCompactionStrategy
impl UnsafeUnpin for ToolResultCompactionStrategy
Blanket Implementations§
Source§impl<T> AsyncCompactionStrategy for Twhere
T: CompactionStrategy,
impl<T> AsyncCompactionStrategy for Twhere
T: CompactionStrategy,
Source§fn compact_async<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
messages: &'life1 [Message],
tokenizer: &'life2 dyn Tokenizer,
) -> Pin<Box<dyn Future<Output = Vec<Message>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
T: 'async_trait,
fn compact_async<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
messages: &'life1 [Message],
tokenizer: &'life2 dyn Tokenizer,
) -> Pin<Box<dyn Future<Output = Vec<Message>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
T: 'async_trait,
Return the retained messages after compaction.
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