pub struct MiddlewareStack { /* private fields */ }Expand description
Executes a slice of middleware in order.
- If any middleware returns
Terminate, the chain stops. - System prompt additions are collected from all middleware in order.
- Tools are collected from all middleware in order.
Implementations§
Source§impl MiddlewareStack
impl MiddlewareStack
Sourcepub fn push(&mut self, middleware: impl Middleware + 'static)
pub fn push(&mut self, middleware: impl Middleware + 'static)
Append a middleware component to the stack.
Sourcepub async fn run(
&self,
input: MiddlewareInput,
) -> Result<MiddlewareResult, AgentError>
pub async fn run( &self, input: MiddlewareInput, ) -> Result<MiddlewareResult, AgentError>
Run the input through all middleware in order.
Sourcepub fn system_prompt_additions(&self) -> Vec<String>
pub fn system_prompt_additions(&self) -> Vec<String>
Collect all system prompt additions from all middleware in order.
Trait Implementations§
Source§impl Debug for MiddlewareStack
impl Debug for MiddlewareStack
Auto Trait Implementations§
impl Freeze for MiddlewareStack
impl !RefUnwindSafe for MiddlewareStack
impl Send for MiddlewareStack
impl Sync for MiddlewareStack
impl Unpin for MiddlewareStack
impl UnsafeUnpin for MiddlewareStack
impl !UnwindSafe for MiddlewareStack
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