#[non_exhaustive]pub struct BeforeModelCallEvent<'a> { /* private fields */ }Expand description
A model call is about to start (BeforeModelCallEvent).
Implementations§
Source§impl<'a> BeforeModelCallEvent<'a>
impl<'a> BeforeModelCallEvent<'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> BeforeModelCallEvent<'a>
impl<'a> BeforeModelCallEvent<'a>
Sourcepub fn projected_input_tokens(&self) -> Option<u64>
pub fn projected_input_tokens(&self) -> Option<u64>
The projected input tokens of the call, from message metadata and token estimation.
Sourcepub fn set_cancel(&mut self, cancel: impl Into<Cancel>)
pub fn set_cancel(&mut self, cancel: impl Into<Cancel>)
Cancels the model call: true uses the default message, a string becomes the assistant
response.
Trait Implementations§
Source§impl Debug for BeforeModelCallEvent<'_>
impl Debug for BeforeModelCallEvent<'_>
Source§impl From<&BeforeModelCallEvent<'_>> for BeforeModelCallEventData
impl From<&BeforeModelCallEvent<'_>> for BeforeModelCallEventData
Source§fn from(event: &BeforeModelCallEvent<'_>) -> Self
fn from(event: &BeforeModelCallEvent<'_>) -> Self
Converts to this type from the input type.
Source§impl From<&BeforeModelCallEvent<'_>> for AgentStreamEvent
impl From<&BeforeModelCallEvent<'_>> for AgentStreamEvent
Source§fn from(event: &BeforeModelCallEvent<'_>) -> Self
fn from(event: &BeforeModelCallEvent<'_>) -> Self
Converts to this type from the input type.
Source§impl HookEvent for BeforeModelCallEvent<'static>
impl HookEvent for BeforeModelCallEvent<'static>
Source§type Event<'a> = BeforeModelCallEvent<'a>
type Event<'a> = BeforeModelCallEvent<'a>
The event type for an agent borrow of lifetime
'a.impl<H> IntoHookImpl<BeforeModelCallEvent<'static>> for Hwhere
H: for<'a> Hook<BeforeModelCallEvent<'a>>,
impl<F, R> IntoSyncHook<BeforeModelCallEvent<'static>> for Fwhere
F: for<'a, 'b> Fn(&'b mut BeforeModelCallEvent<'a>) -> R + Send + Sync + 'static,
R: HookOutput,
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for BeforeModelCallEvent<'a>
impl<'a> !UnwindSafe for BeforeModelCallEvent<'a>
impl<'a> Freeze for BeforeModelCallEvent<'a>
impl<'a> Send for BeforeModelCallEvent<'a>
impl<'a> Sync for BeforeModelCallEvent<'a>
impl<'a> Unpin for BeforeModelCallEvent<'a>
impl<'a> UnsafeUnpin for BeforeModelCallEvent<'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.