pub struct Callbacks {
pub before_model: Vec<Box<dyn Fn(Arc<dyn CallbackContext>) -> Pin<Box<dyn Future<Output = Result<Option<Content>, AdkError>> + Send>> + Sync + Send>>,
pub after_model: Vec<Box<dyn Fn(Arc<dyn CallbackContext>) -> Pin<Box<dyn Future<Output = Result<Option<Content>, AdkError>> + Send>> + Sync + Send>>,
pub before_tool: Vec<Box<dyn Fn(Arc<dyn CallbackContext>) -> Pin<Box<dyn Future<Output = Result<Option<Content>, AdkError>> + Send>> + Sync + Send>>,
pub after_tool: Vec<Box<dyn Fn(Arc<dyn CallbackContext>) -> Pin<Box<dyn Future<Output = Result<Option<Content>, AdkError>> + Send>> + Sync + Send>>,
}Available on crate feature
runner only.Expand description
Collection of all callback types
Fields§
§before_model: Vec<Box<dyn Fn(Arc<dyn CallbackContext>) -> Pin<Box<dyn Future<Output = Result<Option<Content>, AdkError>> + Send>> + Sync + Send>>§after_model: Vec<Box<dyn Fn(Arc<dyn CallbackContext>) -> Pin<Box<dyn Future<Output = Result<Option<Content>, AdkError>> + Send>> + Sync + Send>>§before_tool: Vec<Box<dyn Fn(Arc<dyn CallbackContext>) -> Pin<Box<dyn Future<Output = Result<Option<Content>, AdkError>> + Send>> + Sync + Send>>§after_tool: Vec<Box<dyn Fn(Arc<dyn CallbackContext>) -> Pin<Box<dyn Future<Output = Result<Option<Content>, AdkError>> + Send>> + Sync + Send>>Implementations§
Source§impl Callbacks
impl Callbacks
pub fn new() -> Callbacks
pub fn add_before_model( &mut self, callback: Box<dyn Fn(Arc<dyn CallbackContext>) -> Pin<Box<dyn Future<Output = Result<Option<Content>, AdkError>> + Send>> + Sync + Send>, )
pub fn add_after_model( &mut self, callback: Box<dyn Fn(Arc<dyn CallbackContext>) -> Pin<Box<dyn Future<Output = Result<Option<Content>, AdkError>> + Send>> + Sync + Send>, )
pub fn add_before_tool( &mut self, callback: Box<dyn Fn(Arc<dyn CallbackContext>) -> Pin<Box<dyn Future<Output = Result<Option<Content>, AdkError>> + Send>> + Sync + Send>, )
pub fn add_after_tool( &mut self, callback: Box<dyn Fn(Arc<dyn CallbackContext>) -> Pin<Box<dyn Future<Output = Result<Option<Content>, AdkError>> + Send>> + Sync + Send>, )
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 !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
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request