pub struct AgUiHook { /* private fields */ }Expand description
AG-UI Hook for streaming tool call events and state updates to frontends.
This hook implements rig’s PromptHook trait to capture tool calls and emit AG-UI protocol events via the EventBridge. It also maintains agent state for generative UI rendering.
Implementations§
Source§impl AgUiHook
impl AgUiHook
Sourcepub fn new(event_bridge: EventBridge) -> Self
pub fn new(event_bridge: EventBridge) -> Self
Creates a new AG-UI hook with the given event bridge.
Sourcepub async fn add_step(&self, description: impl Into<String>)
pub async fn add_step(&self, description: impl Into<String>)
Adds a step and emits state update.
Sourcepub async fn complete_current_step(&self)
pub async fn complete_current_step(&self)
Completes the current step and emits state update.
Trait Implementations§
Source§impl<M> PromptHook<M> for AgUiHookwhere
M: CompletionModel,
impl<M> PromptHook<M> for AgUiHookwhere
M: CompletionModel,
Source§fn on_tool_call(
&self,
tool_name: &str,
_tool_call_id: Option<String>,
args: &str,
_cancel: CancelSignal,
) -> impl Future<Output = ()> + Send
fn on_tool_call( &self, tool_name: &str, _tool_call_id: Option<String>, args: &str, _cancel: CancelSignal, ) -> impl Future<Output = ()> + Send
Called before a tool is invoked.
Source§fn on_tool_result(
&self,
_tool_name: &str,
_tool_call_id: Option<String>,
_args: &str,
result: &str,
_cancel: CancelSignal,
) -> impl Future<Output = ()> + Send
fn on_tool_result( &self, _tool_name: &str, _tool_call_id: Option<String>, _args: &str, result: &str, _cancel: CancelSignal, ) -> impl Future<Output = ()> + Send
Called after a tool is invoked (and a result has been returned).
Source§fn on_completion_response(
&self,
_prompt: &RigPromptMessage,
_response: &CompletionResponse<M::Response>,
_cancel: CancelSignal,
) -> impl Future<Output = ()> + Send
fn on_completion_response( &self, _prompt: &RigPromptMessage, _response: &CompletionResponse<M::Response>, _cancel: CancelSignal, ) -> impl Future<Output = ()> + Send
Called after the prompt is sent to the model and a response is received.
Source§fn on_completion_call(
&self,
prompt: &Message,
history: &[Message],
cancel_sig: CancelSignal,
) -> impl Future<Output = ()> + WasmCompatSend
fn on_completion_call( &self, prompt: &Message, history: &[Message], cancel_sig: CancelSignal, ) -> impl Future<Output = ()> + WasmCompatSend
Called before the prompt is sent to the model
Auto Trait Implementations§
impl Freeze for AgUiHook
impl !RefUnwindSafe for AgUiHook
impl Send for AgUiHook
impl Sync for AgUiHook
impl Unpin for AgUiHook
impl UnsafeUnpin for AgUiHook
impl !UnwindSafe for AgUiHook
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> 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> 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>
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.