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>> + Sync + Send>,
) -> RealtimeAgentBuilder
pub fn instruction_provider( self, provider: Box<dyn Fn(Arc<dyn ReadonlyContext>) -> Pin<Box<dyn Future<Output = Result<String, AdkError>> + Send>> + Sync + Send>, ) -> 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>> + Sync + Send>,
) -> RealtimeAgentBuilder
pub fn global_instruction_provider( self, provider: Box<dyn Fn(Arc<dyn ReadonlyContext>) -> Pin<Box<dyn Future<Output = Result<String, AdkError>> + Send>> + Sync + Send>, ) -> 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>> + Sync + Send>,
) -> RealtimeAgentBuilder
pub fn before_agent_callback( self, callback: Box<dyn Fn(Arc<dyn CallbackContext>) -> Pin<Box<dyn Future<Output = Result<Option<Content>, AdkError>> + Send>> + Sync + Send>, ) -> 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>> + Sync + Send>,
) -> RealtimeAgentBuilder
pub fn after_agent_callback( self, callback: Box<dyn Fn(Arc<dyn CallbackContext>) -> Pin<Box<dyn Future<Output = Result<Option<Content>, AdkError>> + Send>> + Sync + Send>, ) -> 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>> + Sync + Send>,
) -> RealtimeAgentBuilder
pub fn before_tool_callback( self, callback: Box<dyn Fn(Arc<dyn CallbackContext>) -> Pin<Box<dyn Future<Output = Result<Option<Content>, AdkError>> + Send>> + Sync + Send>, ) -> 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>> + Sync + Send>,
) -> RealtimeAgentBuilder
pub fn after_tool_callback( self, callback: Box<dyn Fn(Arc<dyn CallbackContext>) -> Pin<Box<dyn Future<Output = Result<Option<Content>, AdkError>> + Send>> + Sync + Send>, ) -> RealtimeAgentBuilder
Add an after-tool callback.
Sourcepub fn on_audio(
self,
callback: Arc<dyn Fn(&[u8], &str) -> Pin<Box<dyn Future<Output = ()> + Send>> + Sync + Send>,
) -> RealtimeAgentBuilder
pub fn on_audio( self, callback: Arc<dyn Fn(&[u8], &str) -> Pin<Box<dyn Future<Output = ()> + Send>> + Sync + Send>, ) -> RealtimeAgentBuilder
Set callback for audio output events.
Sourcepub fn on_transcript(
self,
callback: Arc<dyn Fn(&str, &str) -> Pin<Box<dyn Future<Output = ()> + Send>> + Sync + Send>,
) -> RealtimeAgentBuilder
pub fn on_transcript( self, callback: Arc<dyn Fn(&str, &str) -> Pin<Box<dyn Future<Output = ()> + Send>> + Sync + Send>, ) -> RealtimeAgentBuilder
Set callback for transcript events.
Sourcepub fn on_speech_started(
self,
callback: Arc<dyn Fn(u64) -> Pin<Box<dyn Future<Output = ()> + Send>> + Sync + Send>,
) -> RealtimeAgentBuilder
pub fn on_speech_started( self, callback: Arc<dyn Fn(u64) -> Pin<Box<dyn Future<Output = ()> + Send>> + Sync + Send>, ) -> RealtimeAgentBuilder
Set callback for speech started events.
Sourcepub fn on_speech_stopped(
self,
callback: Arc<dyn Fn(u64) -> Pin<Box<dyn Future<Output = ()> + Send>> + Sync + Send>,
) -> RealtimeAgentBuilder
pub fn on_speech_stopped( self, callback: Arc<dyn Fn(u64) -> Pin<Box<dyn Future<Output = ()> + Send>> + Sync + Send>, ) -> RealtimeAgentBuilder
Set callback for speech stopped events.
Sourcepub fn build(self) -> Result<RealtimeAgent, AdkError>
pub fn build(self) -> Result<RealtimeAgent, AdkError>
Build the RealtimeAgent.