#[non_exhaustive]pub struct BeforeInvocationEvent<'a> { /* private fields */ }Expand description
A new request is starting, before any model call or tool runs (BeforeInvocationEvent).
Implementations§
Source§impl<'a> BeforeInvocationEvent<'a>
impl<'a> BeforeInvocationEvent<'a>
Sourcepub fn agent(&self) -> &LocalAgent
pub fn agent(&self) -> &LocalAgent
The agent.
Sourcepub fn agent_mut(&mut self) -> &mut LocalAgent
pub fn agent_mut(&mut self) -> &mut LocalAgent
The agent, mutably: hooks may change its messages, system prompt, tools and state.
Sourcepub fn invocation_state(&self) -> &InvocationState
pub fn invocation_state(&self) -> &InvocationState
The caller’s per-invocation state.
Sourcepub fn invocation_context(&self) -> Option<&InvocationContext>
pub fn invocation_context(&self) -> Option<&InvocationContext>
The request this event belongs to.
Source§impl<'a> BeforeInvocationEvent<'a>
impl<'a> BeforeInvocationEvent<'a>
Sourcepub fn messages_mut(&mut self) -> &mut Vec<Message>
pub fn messages_mut(&mut self) -> &mut Vec<Message>
The input messages, to edit before processing.
Sourcepub fn set_messages(&mut self, messages: Vec<Message>)
pub fn set_messages(&mut self, messages: Vec<Message>)
Replaces the input messages.
Sourcepub fn set_cancel(&mut self, cancel: impl Into<Cancel>)
pub fn set_cancel(&mut self, cancel: impl Into<Cancel>)
Cancels the invocation: true uses the default message, a string becomes the assistant
response.
Trait Implementations§
Source§impl Debug for BeforeInvocationEvent<'_>
impl Debug for BeforeInvocationEvent<'_>
Source§impl From<&BeforeInvocationEvent<'_>> for BeforeInvocationEventData
impl From<&BeforeInvocationEvent<'_>> for BeforeInvocationEventData
Source§fn from(_: &BeforeInvocationEvent<'_>) -> Self
fn from(_: &BeforeInvocationEvent<'_>) -> Self
Converts to this type from the input type.
Source§impl From<&BeforeInvocationEvent<'_>> for AgentStreamEvent
impl From<&BeforeInvocationEvent<'_>> for AgentStreamEvent
Source§fn from(event: &BeforeInvocationEvent<'_>) -> Self
fn from(event: &BeforeInvocationEvent<'_>) -> Self
Converts to this type from the input type.
Source§impl HookEvent for BeforeInvocationEvent<'static>
impl HookEvent for BeforeInvocationEvent<'static>
Source§type Event<'a> = BeforeInvocationEvent<'a>
type Event<'a> = BeforeInvocationEvent<'a>
The event type for an agent borrow of lifetime
'a.impl<H> IntoHookImpl<BeforeInvocationEvent<'static>> for Hwhere
H: for<'a> Hook<BeforeInvocationEvent<'a>>,
impl<F, R> IntoSyncHook<BeforeInvocationEvent<'static>> for Fwhere
F: for<'a, 'b> Fn(&'b mut BeforeInvocationEvent<'a>) -> R + Send + Sync + 'static,
R: HookOutput,
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for BeforeInvocationEvent<'a>
impl<'a> !UnwindSafe for BeforeInvocationEvent<'a>
impl<'a> Freeze for BeforeInvocationEvent<'a>
impl<'a> Send for BeforeInvocationEvent<'a>
impl<'a> Sync for BeforeInvocationEvent<'a>
impl<'a> Unpin for BeforeInvocationEvent<'a>
impl<'a> UnsafeUnpin for BeforeInvocationEvent<'a>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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> ⓘ
Converts
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> ⓘ
Converts
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 moreCreates a shared type from an unshared type.