pub struct RealtimeAgentBuilder { /* private fields */ }realtime only.Expand description
Builder for RealtimeAgent.
Implementations§
Source§impl RealtimeAgentBuilder
impl RealtimeAgentBuilder
Sourcepub fn new(name: impl Into<String>) -> RealtimeAgentBuilder
pub fn new(name: impl Into<String>) -> RealtimeAgentBuilder
Create a new builder with the given agent name.
Sourcepub fn description(self, desc: impl Into<String>) -> RealtimeAgentBuilder
pub fn description(self, desc: impl Into<String>) -> RealtimeAgentBuilder
Set the agent description.
Sourcepub fn model(self, model: Arc<dyn RealtimeModel>) -> RealtimeAgentBuilder
pub fn model(self, model: Arc<dyn RealtimeModel>) -> RealtimeAgentBuilder
Set the realtime model.
Sourcepub fn instruction(self, instruction: impl Into<String>) -> RealtimeAgentBuilder
pub fn instruction(self, instruction: impl Into<String>) -> RealtimeAgentBuilder
Set a static instruction.
Sourcepub fn instruction_provider(
self,
provider: Box<dyn Fn(Arc<dyn ReadonlyContext>) -> Pin<Box<dyn Future<Output = Result<String, AdkError>> + Send>> + Send + Sync>,
) -> RealtimeAgentBuilder
pub fn instruction_provider( self, provider: Box<dyn Fn(Arc<dyn ReadonlyContext>) -> Pin<Box<dyn Future<Output = Result<String, AdkError>> + Send>> + Send + Sync>, ) -> RealtimeAgentBuilder
Set a dynamic instruction provider.
Sourcepub fn global_instruction(
self,
instruction: impl Into<String>,
) -> RealtimeAgentBuilder
pub fn global_instruction( self, instruction: impl Into<String>, ) -> RealtimeAgentBuilder
Set a static global instruction.
Sourcepub fn global_instruction_provider(
self,
provider: Box<dyn Fn(Arc<dyn ReadonlyContext>) -> Pin<Box<dyn Future<Output = Result<String, AdkError>> + Send>> + Send + Sync>,
) -> RealtimeAgentBuilder
pub fn global_instruction_provider( self, provider: Box<dyn Fn(Arc<dyn ReadonlyContext>) -> Pin<Box<dyn Future<Output = Result<String, AdkError>> + Send>> + Send + Sync>, ) -> RealtimeAgentBuilder
Set a dynamic global instruction provider.
Sourcepub fn voice(self, voice: impl Into<String>) -> RealtimeAgentBuilder
pub fn voice(self, voice: impl Into<String>) -> RealtimeAgentBuilder
Set the voice for audio output.
Sourcepub fn vad(self, config: VadConfig) -> RealtimeAgentBuilder
pub fn vad(self, config: VadConfig) -> RealtimeAgentBuilder
Set voice activity detection configuration.
Sourcepub fn server_vad(self) -> RealtimeAgentBuilder
pub fn server_vad(self) -> RealtimeAgentBuilder
Enable server-side VAD with default settings.
Sourcepub fn modalities(self, modalities: Vec<String>) -> RealtimeAgentBuilder
pub fn modalities(self, modalities: Vec<String>) -> RealtimeAgentBuilder
Set output modalities (e.g., [“text”, “audio”]).
Sourcepub fn tool(self, tool: Arc<dyn Tool>) -> RealtimeAgentBuilder
pub fn tool(self, tool: Arc<dyn Tool>) -> RealtimeAgentBuilder
Add a tool.
Sourcepub fn toolset(self, toolset: Arc<dyn Toolset>) -> RealtimeAgentBuilder
pub fn toolset(self, toolset: Arc<dyn Toolset>) -> RealtimeAgentBuilder
Register a dynamic toolset for per-invocation tool resolution.
Toolsets are resolved at the start of each run() call using the
invocation’s ReadonlyContext. This enables context-dependent tools
like per-user browser sessions from a pool.
Sourcepub fn sub_agent(self, agent: Arc<dyn Agent>) -> RealtimeAgentBuilder
pub fn sub_agent(self, agent: Arc<dyn Agent>) -> RealtimeAgentBuilder
Add a sub-agent for handoffs.
Sourcepub fn before_agent_callback(
self,
callback: Box<dyn Fn(Arc<dyn CallbackContext>) -> Pin<Box<dyn Future<Output = Result<Option<Content>, AdkError>> + Send>> + Send + Sync>,
) -> RealtimeAgentBuilder
pub fn before_agent_callback( self, callback: Box<dyn Fn(Arc<dyn CallbackContext>) -> Pin<Box<dyn Future<Output = Result<Option<Content>, AdkError>> + Send>> + Send + Sync>, ) -> RealtimeAgentBuilder
Add a before-agent callback.
Sourcepub fn after_agent_callback(
self,
callback: Box<dyn Fn(Arc<dyn CallbackContext>) -> Pin<Box<dyn Future<Output = Result<Option<Content>, AdkError>> + Send>> + Send + Sync>,
) -> RealtimeAgentBuilder
pub fn after_agent_callback( self, callback: Box<dyn Fn(Arc<dyn CallbackContext>) -> Pin<Box<dyn Future<Output = Result<Option<Content>, AdkError>> + Send>> + Send + Sync>, ) -> RealtimeAgentBuilder
Add an after-agent callback.
Sourcepub fn before_tool_callback(
self,
callback: Box<dyn Fn(Arc<dyn CallbackContext>) -> Pin<Box<dyn Future<Output = Result<Option<Content>, AdkError>> + Send>> + Send + Sync>,
) -> RealtimeAgentBuilder
pub fn before_tool_callback( self, callback: Box<dyn Fn(Arc<dyn CallbackContext>) -> Pin<Box<dyn Future<Output = Result<Option<Content>, AdkError>> + Send>> + Send + Sync>, ) -> RealtimeAgentBuilder
Add a before-tool callback.
Sourcepub fn after_tool_callback(
self,
callback: Box<dyn Fn(Arc<dyn CallbackContext>) -> Pin<Box<dyn Future<Output = Result<Option<Content>, AdkError>> + Send>> + Send + Sync>,
) -> RealtimeAgentBuilder
pub fn after_tool_callback( self, callback: Box<dyn Fn(Arc<dyn CallbackContext>) -> Pin<Box<dyn Future<Output = Result<Option<Content>, AdkError>> + Send>> + Send + Sync>, ) -> RealtimeAgentBuilder
Add an after-tool callback.
Sourcepub fn on_audio(
self,
callback: Arc<dyn Fn(&[u8], &str) -> Pin<Box<dyn Future<Output = ()> + Send>> + Send + Sync>,
) -> RealtimeAgentBuilder
pub fn on_audio( self, callback: Arc<dyn Fn(&[u8], &str) -> Pin<Box<dyn Future<Output = ()> + Send>> + Send + Sync>, ) -> RealtimeAgentBuilder
Set callback for audio output events.
Sourcepub fn on_transcript(
self,
callback: Arc<dyn Fn(&str, &str) -> Pin<Box<dyn Future<Output = ()> + Send>> + Send + Sync>,
) -> RealtimeAgentBuilder
pub fn on_transcript( self, callback: Arc<dyn Fn(&str, &str) -> Pin<Box<dyn Future<Output = ()> + Send>> + Send + Sync>, ) -> RealtimeAgentBuilder
Set callback for transcript events.
Sourcepub fn on_speech_started(
self,
callback: Arc<dyn Fn(u64) -> Pin<Box<dyn Future<Output = ()> + Send>> + Send + Sync>,
) -> RealtimeAgentBuilder
pub fn on_speech_started( self, callback: Arc<dyn Fn(u64) -> Pin<Box<dyn Future<Output = ()> + Send>> + Send + Sync>, ) -> RealtimeAgentBuilder
Set callback for speech started events.
Sourcepub fn on_speech_stopped(
self,
callback: Arc<dyn Fn(u64) -> Pin<Box<dyn Future<Output = ()> + Send>> + Send + Sync>,
) -> RealtimeAgentBuilder
pub fn on_speech_stopped( self, callback: Arc<dyn Fn(u64) -> Pin<Box<dyn Future<Output = ()> + Send>> + Send + Sync>, ) -> RealtimeAgentBuilder
Set callback for speech stopped events.
Sourcepub fn build(self) -> Result<RealtimeAgent, AdkError>
pub fn build(self) -> Result<RealtimeAgent, AdkError>
Build the RealtimeAgent.
Auto Trait Implementations§
impl Freeze for RealtimeAgentBuilder
impl !RefUnwindSafe for RealtimeAgentBuilder
impl Send for RealtimeAgentBuilder
impl Sync for RealtimeAgentBuilder
impl Unpin for RealtimeAgentBuilder
impl UnsafeUnpin for RealtimeAgentBuilder
impl !UnwindSafe for RealtimeAgentBuilder
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> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<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>
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request