pub struct MiddlewareChain { /* private fields */ }Expand description
Ordered chain of middleware.
Implementations§
Source§impl MiddlewareChain
impl MiddlewareChain
Sourcepub fn add(&mut self, middleware: Arc<dyn Middleware>)
pub fn add(&mut self, middleware: Arc<dyn Middleware>)
Append a middleware to the end of the chain.
Sourcepub fn prepend(&mut self, middleware: Arc<dyn Middleware>)
pub fn prepend(&mut self, middleware: Arc<dyn Middleware>)
Prepend a middleware to the front of the chain.
Sourcepub async fn run_before_agent(
&self,
ctx: &InvocationContext,
) -> Result<(), AgentError>
pub async fn run_before_agent( &self, ctx: &InvocationContext, ) -> Result<(), AgentError>
Run all before_agent hooks in order.
Sourcepub async fn run_after_agent(
&self,
ctx: &InvocationContext,
) -> Result<(), AgentError>
pub async fn run_after_agent( &self, ctx: &InvocationContext, ) -> Result<(), AgentError>
Run all after_agent hooks in reverse order.
Sourcepub async fn run_before_tool(
&self,
call: &FunctionCall,
) -> Result<(), AgentError>
pub async fn run_before_tool( &self, call: &FunctionCall, ) -> Result<(), AgentError>
Run all before_tool hooks in order.
Sourcepub async fn run_after_tool(
&self,
call: &FunctionCall,
result: &Value,
) -> Result<(), AgentError>
pub async fn run_after_tool( &self, call: &FunctionCall, result: &Value, ) -> Result<(), AgentError>
Run all after_tool hooks in reverse order.
Sourcepub async fn run_on_tool_error(
&self,
call: &FunctionCall,
err: &ToolError,
) -> Result<(), AgentError>
pub async fn run_on_tool_error( &self, call: &FunctionCall, err: &ToolError, ) -> Result<(), AgentError>
Run all on_tool_error hooks in order.
Sourcepub async fn run_on_event(&self, event: &AgentEvent) -> Result<(), AgentError>
pub async fn run_on_event(&self, event: &AgentEvent) -> Result<(), AgentError>
Run all on_event hooks in order.
Sourcepub async fn run_on_error(&self, err: &AgentError) -> Result<(), AgentError>
pub async fn run_on_error(&self, err: &AgentError) -> Result<(), AgentError>
Run all on_error hooks in order.
Sourcepub async fn run_before_model(
&self,
request: &LlmRequest,
) -> Result<Option<LlmResponse>, AgentError>
pub async fn run_before_model( &self, request: &LlmRequest, ) -> Result<Option<LlmResponse>, AgentError>
Run all before_model hooks in order. Returns the first non-None override response.
Sourcepub async fn run_after_model(
&self,
request: &LlmRequest,
response: &LlmResponse,
) -> Result<Option<LlmResponse>, AgentError>
pub async fn run_after_model( &self, request: &LlmRequest, response: &LlmResponse, ) -> Result<Option<LlmResponse>, AgentError>
Run all after_model hooks in reverse order. Returns the first non-None override response.
Trait Implementations§
Source§impl Clone for MiddlewareChain
impl Clone for MiddlewareChain
Source§fn clone(&self) -> MiddlewareChain
fn clone(&self) -> MiddlewareChain
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 Default for MiddlewareChain
impl Default for MiddlewareChain
Source§fn default() -> MiddlewareChain
fn default() -> MiddlewareChain
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for MiddlewareChain
impl !RefUnwindSafe for MiddlewareChain
impl Send for MiddlewareChain
impl Sync for MiddlewareChain
impl Unpin for MiddlewareChain
impl UnsafeUnpin for MiddlewareChain
impl !UnwindSafe for MiddlewareChain
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