pub trait RealtimeLlmService: Send {
// Required methods
fn connect<'life0, 'async_trait>(
&'life0 mut self,
setup: RealtimeServiceSetup,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn send_audio<'life0, 'async_trait>(
&'life0 mut self,
chunk: Arc<AudioFrame>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn update_system<'life0, 'async_trait>(
&'life0 mut self,
prompt: String,
tools: Vec<Tool>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn send_tool_result<'life0, 'async_trait>(
&'life0 mut self,
id: String,
result: Value,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn next_event<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Option<RealtimeEvent>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided methods
fn input_sample_rate(&self) -> u32 { ... }
fn kickoff<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn event_notify(&self) -> Option<Arc<Notify>> { ... }
fn poll_event<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = PollEvent> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
}Expand description
The realtime S2S contract (today’s crate::realtime::RealtimeLlm — UNCHANGED
shape, restated as the canonical service trait the processor wraps).
Required Methods§
fn connect<'life0, 'async_trait>(
&'life0 mut self,
setup: RealtimeServiceSetup,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn send_audio<'life0, 'async_trait>(
&'life0 mut self,
chunk: Arc<AudioFrame>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn update_system<'life0, 'async_trait>(
&'life0 mut self,
prompt: String,
tools: Vec<Tool>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn send_tool_result<'life0, 'async_trait>(
&'life0 mut self,
id: String,
result: Value,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn next_event<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Option<RealtimeEvent>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Provided Methods§
Sourcefn input_sample_rate(&self) -> u32
fn input_sample_rate(&self) -> u32
The PCM sample rate (Hz) this model expects on its audio input. The s2s
pipeline resamples caller audio to this before send_audio and advertises it
in RealtimeSetup::input_sample_rate. Default 16 kHz; a provider that needs
another rate (OpenAI Realtime requires ≥ 24 kHz) overrides this. Lives on the
connector so the consuming app never has to know provider rates.
Sourcefn kickoff<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn kickoff<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Trigger an initial bot-first turn so the agent greets before the caller
speaks. Default no-op (caller speaks first); a provider that supports it
overrides (e.g. OpenAI Realtime sends a response.create). The pipeline calls
this through ServiceRealtimeAdapter
→ RealtimeKickoff.
Sourcefn event_notify(&self) -> Option<Arc<Notify>>
fn event_notify(&self) -> Option<Arc<Notify>>
Readiness notify for the lock-free event path (mirrors
RealtimeLlm::event_notify).
None (default) → the pipeline falls back to the blocking next_event, which
holds the session lock across the idle wait between bot turns and starves
send_audio (caller audio stalls after the greeting). A connector with an
internal event channel SHOULD return a Notify it fires on each event so the
pipeline can await readiness without the lock.
Sourcefn poll_event<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = PollEvent> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn poll_event<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = PollEvent> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Non-blocking sibling of next_event (mirrors
RealtimeLlm::poll_event). The
default blocks; a connector that returns a real event_notify
MUST override this to be genuinely non-blocking (e.g. a channel try_recv).
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".