pub struct AgentEndpoint<A> { /* private fields */ }Expand description
An agent plus the per-run settings it is served with.
route_agui mounts an agent with the defaults;
build one of these and use route_agui_with
when you want to change them.
use ag_ui::axum::{AgentEndpoint, RouterExt};
use ag_ui::server::FilterToolCalls;
use axum::Router;
use std::time::Duration;
let endpoint = AgentEndpoint::new(CartAgent)
.transformer(|| FilterToolCalls::deny(["internal_debug"]))
.keep_alive(Duration::from_secs(15));
let app: Router = Router::new().route_agui_with("/agent", endpoint);Implementations§
Source§impl<A> AgentEndpoint<A>
impl<A> AgentEndpoint<A>
Sourcepub fn transformer<F, T>(self, factory: F) -> Self
pub fn transformer<F, T>(self, factory: F) -> Self
Appends a transformer to every run’s chain.
§Why a closure and not a transformer
A StreamTransformer takes &mut self because a useful one is a
state machine — FilterToolCalls
remembers which call ids it dropped. One instance shared across
concurrent runs would leak one run’s state into another, so the endpoint
stores the recipe and builds a fresh chain per request.
Sourcepub fn echo_input(self, echo: bool) -> Self
pub fn echo_input(self, echo: bool) -> Self
Echoes the request body back on RUN_STARTED.
See Runner::echo_input. Off by default — it is the largest payload
in the protocol.
Sourcepub fn keep_alive(self, interval: Duration) -> Self
pub fn keep_alive(self, interval: Duration) -> Self
Sends an SSE comment whenever a run produces nothing for interval.
See SseResponse::keep_alive. Off by default.
Trait Implementations§
Auto Trait Implementations§
impl<A> !RefUnwindSafe for AgentEndpoint<A>
impl<A> !UnwindSafe for AgentEndpoint<A>
impl<A> Freeze for AgentEndpoint<A>
impl<A> Send for AgentEndpoint<A>
impl<A> Sync for AgentEndpoint<A>
impl<A> Unpin for AgentEndpoint<A>
impl<A> UnsafeUnpin for AgentEndpoint<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