pub struct Callbacks {
pub before_model: Vec<Box<dyn Fn(Arc<dyn CallbackContext>) -> Pin<Box<dyn Future<Output = Result<Option<Content>, AdkError>> + Send>> + Send + Sync>>,
pub after_model: Vec<Box<dyn Fn(Arc<dyn CallbackContext>) -> Pin<Box<dyn Future<Output = Result<Option<Content>, AdkError>> + Send>> + Send + Sync>>,
pub before_tool: Vec<Box<dyn Fn(Arc<dyn CallbackContext>) -> Pin<Box<dyn Future<Output = Result<Option<Content>, AdkError>> + Send>> + Send + Sync>>,
pub after_tool: Vec<Box<dyn Fn(Arc<dyn CallbackContext>) -> Pin<Box<dyn Future<Output = Result<Option<Content>, AdkError>> + Send>> + Send + Sync>>,
}Available on crate feature
runner only.Expand description
Collection of all callback types for intercepting model and tool execution.
Fields§
§before_model: Vec<Box<dyn Fn(Arc<dyn CallbackContext>) -> Pin<Box<dyn Future<Output = Result<Option<Content>, AdkError>> + Send>> + Send + Sync>>Callbacks invoked before each model call.
after_model: Vec<Box<dyn Fn(Arc<dyn CallbackContext>) -> Pin<Box<dyn Future<Output = Result<Option<Content>, AdkError>> + Send>> + Send + Sync>>Callbacks invoked after each model call.
before_tool: Vec<Box<dyn Fn(Arc<dyn CallbackContext>) -> Pin<Box<dyn Future<Output = Result<Option<Content>, AdkError>> + Send>> + Send + Sync>>Callbacks invoked before each tool execution.
after_tool: Vec<Box<dyn Fn(Arc<dyn CallbackContext>) -> Pin<Box<dyn Future<Output = Result<Option<Content>, AdkError>> + Send>> + Send + Sync>>Callbacks invoked after each tool execution.
Implementations§
Source§impl Callbacks
impl Callbacks
Sourcepub fn add_before_model(
&mut self,
callback: Box<dyn Fn(Arc<dyn CallbackContext>) -> Pin<Box<dyn Future<Output = Result<Option<Content>, AdkError>> + Send>> + Send + Sync>,
)
pub fn add_before_model( &mut self, callback: Box<dyn Fn(Arc<dyn CallbackContext>) -> Pin<Box<dyn Future<Output = Result<Option<Content>, AdkError>> + Send>> + Send + Sync>, )
Register a callback to run before each model call.
Sourcepub fn add_after_model(
&mut self,
callback: Box<dyn Fn(Arc<dyn CallbackContext>) -> Pin<Box<dyn Future<Output = Result<Option<Content>, AdkError>> + Send>> + Send + Sync>,
)
pub fn add_after_model( &mut self, callback: Box<dyn Fn(Arc<dyn CallbackContext>) -> Pin<Box<dyn Future<Output = Result<Option<Content>, AdkError>> + Send>> + Send + Sync>, )
Register a callback to run after each model call.
Sourcepub fn add_before_tool(
&mut self,
callback: Box<dyn Fn(Arc<dyn CallbackContext>) -> Pin<Box<dyn Future<Output = Result<Option<Content>, AdkError>> + Send>> + Send + Sync>,
)
pub fn add_before_tool( &mut self, callback: Box<dyn Fn(Arc<dyn CallbackContext>) -> Pin<Box<dyn Future<Output = Result<Option<Content>, AdkError>> + Send>> + Send + Sync>, )
Register a callback to run before each tool execution.
Sourcepub fn add_after_tool(
&mut self,
callback: Box<dyn Fn(Arc<dyn CallbackContext>) -> Pin<Box<dyn Future<Output = Result<Option<Content>, AdkError>> + Send>> + Send + Sync>,
)
pub fn add_after_tool( &mut self, callback: Box<dyn Fn(Arc<dyn CallbackContext>) -> Pin<Box<dyn Future<Output = Result<Option<Content>, AdkError>> + Send>> + Send + Sync>, )
Register a callback to run after each tool execution.
Sourcepub async fn execute_before_model(
&self,
ctx: Arc<dyn CallbackContext>,
) -> Result<Vec<Content>, AdkError>
pub async fn execute_before_model( &self, ctx: Arc<dyn CallbackContext>, ) -> Result<Vec<Content>, AdkError>
Execute all before_model callbacks
Sourcepub async fn execute_after_model(
&self,
ctx: Arc<dyn CallbackContext>,
) -> Result<Vec<Content>, AdkError>
pub async fn execute_after_model( &self, ctx: Arc<dyn CallbackContext>, ) -> Result<Vec<Content>, AdkError>
Execute all after_model callbacks
Sourcepub async fn execute_before_tool(
&self,
ctx: Arc<dyn CallbackContext>,
) -> Result<Vec<Content>, AdkError>
pub async fn execute_before_tool( &self, ctx: Arc<dyn CallbackContext>, ) -> Result<Vec<Content>, AdkError>
Execute all before_tool callbacks
Sourcepub async fn execute_after_tool(
&self,
ctx: Arc<dyn CallbackContext>,
) -> Result<Vec<Content>, AdkError>
pub async fn execute_after_tool( &self, ctx: Arc<dyn CallbackContext>, ) -> Result<Vec<Content>, AdkError>
Execute all after_tool callbacks
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Callbacks
impl !RefUnwindSafe for Callbacks
impl Send for Callbacks
impl Sync for Callbacks
impl Unpin for Callbacks
impl UnsafeUnpin for Callbacks
impl !UnwindSafe for Callbacks
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