pub enum Hook {
BeforeAll(Box<dyn BeforeAllFn>),
BeforeCompletion(Box<dyn BeforeCompletionFn>),
AfterCompletion(Box<dyn AfterCompletionFn>),
BeforeTool(Box<dyn BeforeToolFn>),
AfterTool(Box<dyn AfterToolFn>),
AfterEach(Box<dyn AfterEachFn>),
OnNewMessage(Box<dyn MessageHookFn>),
OnStart(Box<dyn OnStartFn>),
OnStop(Box<dyn OnStopFn>),
OnStream(Box<dyn OnStreamFn>),
}
Expand description
Wrapper around the different types of hooks
Variants§
BeforeAll(Box<dyn BeforeAllFn>)
Runs only once for the agent when it starts
BeforeCompletion(Box<dyn BeforeCompletionFn>)
Runs before every completion, yielding a mutable reference to the completion request
AfterCompletion(Box<dyn AfterCompletionFn>)
Runs after every completion, yielding a mutable reference to the completion response
BeforeTool(Box<dyn BeforeToolFn>)
Runs before every tool call, yielding a reference to the tool call
AfterTool(Box<dyn AfterToolFn>)
Runs after every tool call, yielding a reference to the tool call and a mutable result
AfterEach(Box<dyn AfterEachFn>)
Runs after all tools have completed and a single completion has been made
OnNewMessage(Box<dyn MessageHookFn>)
Runs when a new message is added to the AgentContext
, yielding a mutable reference to the
message. This is only triggered when the message is added by the agent.
OnStart(Box<dyn OnStartFn>)
Runs when the agent starts, either from pending or stopped
OnStop(Box<dyn OnStopFn>)
Runs when the agent stops
OnStream(Box<dyn OnStreamFn>)
Runs when the agent streams a response
Trait Implementations§
Source§impl IntoDiscriminant for Hook
impl IntoDiscriminant for Hook
Source§type Discriminant = HookTypes
type Discriminant = HookTypes
fn discriminant(&self) -> Self::Discriminant
Auto Trait Implementations§
impl Freeze for Hook
impl !RefUnwindSafe for Hook
impl Send for Hook
impl Sync for Hook
impl Unpin for Hook
impl !UnwindSafe for Hook
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more