Skip to main content

adk_realtime/
config.rs

1//! Configuration types for realtime sessions.
2
3use crate::audio::AudioEncoding;
4use serde::{Deserialize, Serialize};
5use serde_json::Value;
6use std::ops::{Deref, DerefMut};
7
8/// Controls how the realtime session handles user interruptions during agent
9/// audio output.
10///
11/// When set to [`Automatic`](InterruptionDetection::Automatic), the session
12/// uses voice activity detection to detect user speech onset and immediately
13/// cancels the current agent audio output, enabling natural conversational
14/// turn-taking.
15///
16/// When set to [`Manual`](InterruptionDetection::Manual) (the default), the
17/// session relies on explicit API calls (e.g. `response.cancel`) to signal
18/// that the user is interrupting. This gives the application full control
19/// over interruption behavior.
20#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize)]
21#[serde(rename_all = "snake_case")]
22pub enum InterruptionDetection {
23    /// Rely on explicit API calls to signal interruptions.
24    ///
25    /// The application is responsible for detecting user speech and calling
26    /// the appropriate cancellation method on the session. No automatic
27    /// voice activity detection is performed for interruption purposes.
28    #[default]
29    Manual,
30    /// Detect user speech onset and cancel the current agent audio output.
31    ///
32    /// The session monitors incoming audio for voice activity. When user
33    /// speech is detected while the agent is producing audio, the agent's
34    /// audio output is automatically cancelled, allowing the user to
35    /// take the conversational turn.
36    Automatic,
37}
38
39/// Voice Activity Detection mode.
40#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Default)]
41#[serde(rename_all = "snake_case")]
42pub enum VadMode {
43    /// Server-side VAD (default for most providers).
44    #[default]
45    ServerVad,
46    /// Semantic VAD (OpenAI-specific).
47    SemanticVad,
48    /// No automatic VAD - manual turn management.
49    ///
50    /// **The application becomes responsible for turn detection.** On Gemini
51    /// Live this sends
52    /// `setup.realtimeInputConfig.automaticActivityDetection.disabled = true`,
53    /// after which the server performs no turn detection at all and the client
54    /// must send `activityStart` / `activityEnd` itself, via the
55    /// `ActivitySignaller` that a Gemini session offers only in this mode.
56    /// Selecting this and never signalling leaves a session that never takes
57    /// a turn.
58    None,
59}
60
61/// VAD configuration options.
62#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
63pub struct VadConfig {
64    /// VAD mode to use.
65    #[serde(rename = "type")]
66    pub mode: VadMode,
67    /// Silence duration (ms) before considering speech ended.
68    #[serde(skip_serializing_if = "Option::is_none")]
69    pub silence_duration_ms: Option<u32>,
70    /// Detection threshold (0.0 - 1.0).
71    #[serde(skip_serializing_if = "Option::is_none")]
72    pub threshold: Option<f32>,
73    /// Prefix padding (ms) to include before detected speech.
74    #[serde(skip_serializing_if = "Option::is_none")]
75    pub prefix_padding_ms: Option<u32>,
76    /// Whether to interrupt the model when user starts speaking.
77    #[serde(skip_serializing_if = "Option::is_none")]
78    pub interrupt_response: Option<bool>,
79    /// Eagerness of turn detection (OpenAI-specific).
80    #[serde(skip_serializing_if = "Option::is_none")]
81    pub eagerness: Option<String>,
82}
83
84impl Default for VadConfig {
85    fn default() -> Self {
86        Self {
87            mode: VadMode::ServerVad,
88            silence_duration_ms: Some(500),
89            threshold: None,
90            prefix_padding_ms: None,
91            interrupt_response: Some(true),
92            eagerness: None,
93        }
94    }
95}
96
97impl VadConfig {
98    /// Create a server VAD config with default settings.
99    pub fn server_vad() -> Self {
100        Self::default()
101    }
102
103    /// Create a semantic VAD config (OpenAI).
104    pub fn semantic_vad() -> Self {
105        Self { mode: VadMode::SemanticVad, ..Default::default() }
106    }
107
108    /// Create a config with VAD disabled.
109    pub fn disabled() -> Self {
110        Self { mode: VadMode::None, ..Default::default() }
111    }
112
113    /// Set silence duration threshold.
114    pub fn with_silence_duration(mut self, ms: u32) -> Self {
115        self.silence_duration_ms = Some(ms);
116        self
117    }
118
119    /// Set whether to interrupt on user speech.
120    pub fn with_interrupt(mut self, interrupt: bool) -> Self {
121        self.interrupt_response = Some(interrupt);
122        self
123    }
124}
125
126/// Whether the model waits for a tool's result before it continues the conversation.
127///
128/// Gemini Live sends it as the function declaration's `behavior`. The OpenAI Realtime API
129/// has no such setting and ignores it.
130///
131/// # Example
132///
133/// ```rust
134/// use adk_realtime::config::{ToolBehavior, ToolDefinition};
135///
136/// let notify = ToolDefinition::new("notify_team").with_behavior(ToolBehavior::NonBlocking);
137/// assert_eq!(notify.behavior, Some(ToolBehavior::NonBlocking));
138/// ```
139#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
140#[serde(rename_all = "snake_case")]
141pub enum ToolBehavior {
142    /// The model pauses until the result arrives, then answers with it in the same turn.
143    Blocking,
144    /// The model keeps talking while the tool runs and takes the result when it arrives,
145    /// usually in a later turn.
146    NonBlocking,
147}
148
149/// Tool/function definition for realtime sessions.
150#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
151pub struct ToolDefinition {
152    /// Tool name.
153    pub name: String,
154    /// Tool description.
155    #[serde(skip_serializing_if = "Option::is_none")]
156    pub description: Option<String>,
157    /// JSON Schema for parameters.
158    #[serde(skip_serializing_if = "Option::is_none")]
159    pub parameters: Option<Value>,
160    /// Whether the model waits for this tool's result.
161    ///
162    /// `None` lets the session decide: on `gemini-3.8-live` the tool is declared
163    /// [`Blocking`](ToolBehavior::Blocking), so a turn that calls it answers with its result;
164    /// on `gemini-3.8-live-extended-thinking`, which accepts only non-blocking calls,
165    /// [`NonBlocking`](ToolBehavior::NonBlocking); on other models no behavior is declared
166    /// and the model's own default applies.
167    #[serde(default, skip_serializing_if = "Option::is_none")]
168    pub behavior: Option<ToolBehavior>,
169}
170
171impl ToolDefinition {
172    /// Create a new tool definition.
173    pub fn new(name: impl Into<String>) -> Self {
174        Self { name: name.into(), description: None, parameters: None, behavior: None }
175    }
176
177    /// Set whether the model waits for this tool's result.
178    ///
179    /// # Example
180    ///
181    /// ```rust
182    /// use adk_realtime::config::{ToolBehavior, ToolDefinition};
183    ///
184    /// // The model keeps talking while the report is sent.
185    /// let send_report =
186    ///     ToolDefinition::new("send_report").with_behavior(ToolBehavior::NonBlocking);
187    /// assert_eq!(send_report.behavior, Some(ToolBehavior::NonBlocking));
188    /// ```
189    pub fn with_behavior(mut self, behavior: ToolBehavior) -> Self {
190        self.behavior = Some(behavior);
191        self
192    }
193
194    /// Set the tool description.
195    pub fn with_description(mut self, desc: impl Into<String>) -> Self {
196        self.description = Some(desc.into());
197        self
198    }
199
200    /// Set the parameters schema.
201    pub fn with_parameters(mut self, schema: Value) -> Self {
202        self.parameters = Some(schema);
203        self
204    }
205
206    /// The [`ToolOrigin`](adk_core::ToolOrigin) of governed calls to the native handler a
207    /// [`RealtimeRunner`](crate::RealtimeRunner) registers under this definition:
208    /// [`REALTIME_HANDLER_ORIGIN`](crate::runner::REALTIME_HANDLER_ORIGIN) and a digest of
209    /// the name, description, and parameters.
210    ///
211    /// The origin is part of a held call's
212    /// [fingerprint](adk_core::ToolConfirmationRequest::fingerprint), so build a pre-approval
213    /// for a handler's call with it.
214    ///
215    /// # Example
216    ///
217    /// ```rust
218    /// use adk_core::{RunConfig, ToolApproval, ToolConfirmationRequest};
219    /// use adk_realtime::config::ToolDefinition;
220    /// use adk_realtime::runner::REALTIME_HANDLER_ORIGIN;
221    /// use serde_json::json;
222    ///
223    /// let refund = ToolDefinition::new("refund").with_description("Refunds an order");
224    /// assert_eq!(refund.handler_origin().source, REALTIME_HANDLER_ORIGIN);
225    /// let reworded = refund.clone().with_description("Refunds any order");
226    /// assert_ne!(refund.handler_origin(), reworded.handler_origin());
227    ///
228    /// // A runner whose `agent_name` is "voice", in app "shop", acts as this agent.
229    /// let acting = RunConfig::default().acting_context_for("shop", "voice", "alice");
230    /// let key = ToolConfirmationRequest::new("refund", json!({ "order": "A-1" }))
231    ///     .with_origin(refund.handler_origin())
232    ///     .with_acting_context(acting)
233    ///     .fingerprint();
234    /// let config = RunConfig::builder().tool_approval(key, ToolApproval::approve()).build();
235    /// assert_eq!(config.tool_approvals.len(), 1);
236    /// ```
237    pub fn handler_origin(&self) -> adk_core::ToolOrigin {
238        let declaration = serde_json::json!({
239            "name": self.name,
240            "description": self.description,
241            "parameters": self.parameters,
242        });
243        adk_core::ToolOrigin::new(crate::runner::REALTIME_HANDLER_ORIGIN, &declaration, None)
244    }
245}
246
247/// Configuration for a realtime session.
248#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
249pub struct RealtimeConfig {
250    /// Model to use (provider-specific).
251    #[serde(skip_serializing_if = "Option::is_none")]
252    pub model: Option<String>,
253
254    /// System instruction for the agent.
255    #[serde(skip_serializing_if = "Option::is_none")]
256    pub instruction: Option<String>,
257
258    /// Voice to use for audio output.
259    #[serde(skip_serializing_if = "Option::is_none")]
260    pub voice: Option<String>,
261
262    /// Output modalities: ["text"], ["audio"], or ["text", "audio"].
263    #[serde(skip_serializing_if = "Option::is_none")]
264    pub modalities: Option<Vec<String>>,
265
266    /// Input audio format.
267    #[serde(skip_serializing_if = "Option::is_none")]
268    pub input_audio_format: Option<AudioEncoding>,
269
270    /// Output audio format.
271    #[serde(skip_serializing_if = "Option::is_none")]
272    pub output_audio_format: Option<AudioEncoding>,
273
274    /// VAD configuration.
275    #[serde(skip_serializing_if = "Option::is_none")]
276    pub turn_detection: Option<VadConfig>,
277
278    /// Available tools/functions.
279    #[serde(skip_serializing_if = "Option::is_none")]
280    pub tools: Option<Vec<ToolDefinition>>,
281
282    /// Tool selection mode: "auto", "none", "required".
283    #[serde(skip_serializing_if = "Option::is_none")]
284    pub tool_choice: Option<String>,
285
286    /// Whether to include input audio transcription.
287    #[serde(skip_serializing_if = "Option::is_none")]
288    pub input_audio_transcription: Option<TranscriptionConfig>,
289
290    /// Temperature for response generation.
291    #[serde(skip_serializing_if = "Option::is_none")]
292    pub temperature: Option<f32>,
293
294    /// Maximum output tokens.
295    #[serde(skip_serializing_if = "Option::is_none")]
296    pub max_response_output_tokens: Option<u32>,
297
298    /// Cached content resource name (e.g. `cachedContents/1234`).
299    #[serde(skip_serializing_if = "Option::is_none")]
300    pub cached_content: Option<String>,
301
302    /// Interruption detection mode for voice sessions.
303    ///
304    /// Controls whether the session automatically detects user speech to
305    /// cancel agent audio output, or relies on explicit API calls.
306    /// Defaults to [`Manual`](InterruptionDetection::Manual) when `None`.
307    #[serde(skip_serializing_if = "Option::is_none")]
308    pub interruption_detection: Option<InterruptionDetection>,
309
310    /// Enable emotion-aware ("affective") dialog, where the model adapts its
311    /// tone to the user's emotional state. Gemini Live native-audio models only
312    /// (requires the v1alpha endpoint); ignored by other providers.
313    #[serde(skip_serializing_if = "Option::is_none")]
314    pub affective_dialog: Option<bool>,
315
316    /// Provider-specific options.
317    #[serde(skip_serializing_if = "Option::is_none")]
318    pub extra: Option<Value>,
319}
320
321/// A delta payload for safely updating an active realtime session.
322///
323/// Wraps `RealtimeConfig` to prevent struct duplication. Since all fields are
324/// `Option<T>` and skip serialization if `None`, omitting fields preserves
325/// the server's active state.
326///
327/// **⚠️ WARNING:** You must construct a *fresh* configuration containing **only**
328/// the fields to modify. Wrapping your original startup config will resend
329/// immutable fields (like `model`), causing the provider to reject the update.
330///
331/// This is the idiomatic mechanism for dynamic Finite State Machine (FSM) state
332/// transitions, allowing seamless "persona shifts" or tool swaps without
333/// dropping the audio connection.
334///
335/// # Example
336///
337/// ```rust
338/// use adk_realtime::config::{SessionUpdateConfig, RealtimeConfig};
339///
340/// // Update *only* the instruction mid-session.
341/// let delta = SessionUpdateConfig(
342///     RealtimeConfig::default().with_instruction("You are now a travel agent.")
343/// );
344/// ```
345#[derive(Debug, Clone, Default, Serialize, Deserialize)]
346#[serde(transparent)]
347pub struct SessionUpdateConfig(pub RealtimeConfig);
348
349impl Deref for SessionUpdateConfig {
350    type Target = RealtimeConfig;
351
352    fn deref(&self) -> &Self::Target {
353        &self.0
354    }
355}
356
357impl DerefMut for SessionUpdateConfig {
358    fn deref_mut(&mut self) -> &mut Self::Target {
359        &mut self.0
360    }
361}
362
363impl From<RealtimeConfig> for SessionUpdateConfig {
364    fn from(config: RealtimeConfig) -> Self {
365        Self(config)
366    }
367}
368
369/// Transcription configuration.
370#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
371pub struct TranscriptionConfig {
372    /// Transcription model to use.
373    pub model: String,
374}
375
376impl TranscriptionConfig {
377    /// Use whisper-1 for transcription.
378    pub fn whisper() -> Self {
379        Self { model: "whisper-1".to_string() }
380    }
381}
382
383impl RealtimeConfig {
384    /// Create a new empty configuration.
385    pub fn new() -> Self {
386        Self::default()
387    }
388
389    /// Create a builder for RealtimeConfig.
390    pub fn builder() -> RealtimeConfigBuilder {
391        RealtimeConfigBuilder::new()
392    }
393
394    /// Set the model.
395    pub fn with_model(mut self, model: impl Into<String>) -> Self {
396        self.model = Some(model.into());
397        self
398    }
399
400    /// Set the system instruction.
401    pub fn with_instruction(mut self, instruction: impl Into<String>) -> Self {
402        self.instruction = Some(instruction.into());
403        self
404    }
405
406    /// Set the voice.
407    pub fn with_voice(mut self, voice: impl Into<String>) -> Self {
408        self.voice = Some(voice.into());
409        self
410    }
411
412    /// Set output modalities.
413    pub fn with_modalities(mut self, modalities: Vec<String>) -> Self {
414        self.modalities = Some(modalities);
415        self
416    }
417
418    /// Enable text and audio output.
419    pub fn with_text_and_audio(mut self) -> Self {
420        self.modalities = Some(vec!["text".to_string(), "audio".to_string()]);
421        self
422    }
423
424    /// Enable audio-only output.
425    pub fn with_audio_only(mut self) -> Self {
426        self.modalities = Some(vec!["audio".to_string()]);
427        self
428    }
429
430    /// Set VAD configuration.
431    pub fn with_vad(mut self, vad: VadConfig) -> Self {
432        self.turn_detection = Some(vad);
433        self
434    }
435
436    /// Enable server-side VAD with default settings.
437    pub fn with_server_vad(self) -> Self {
438        self.with_vad(VadConfig::server_vad())
439    }
440
441    /// Disable automatic VAD, taking ownership of turn detection.
442    ///
443    /// See [`VadMode::None`] — on Gemini Live this is also what unlocks client
444    /// `activityStart` / `activityEnd` signalling, which the protocol permits
445    /// only while server-side detection is disabled.
446    pub fn without_vad(mut self) -> Self {
447        self.turn_detection = Some(VadConfig::disabled());
448        self
449    }
450
451    /// Add a tool definition.
452    pub fn with_tool(mut self, tool: ToolDefinition) -> Self {
453        self.tools.get_or_insert_with(Vec::new).push(tool);
454        self
455    }
456
457    /// Set multiple tools.
458    pub fn with_tools(mut self, tools: Vec<ToolDefinition>) -> Self {
459        self.tools = Some(tools);
460        self
461    }
462
463    /// Enable input audio transcription.
464    pub fn with_transcription(mut self) -> Self {
465        self.input_audio_transcription = Some(TranscriptionConfig::whisper());
466        self
467    }
468
469    /// Set temperature.
470    pub fn with_temperature(mut self, temp: f32) -> Self {
471        self.temperature = Some(temp);
472        self
473    }
474
475    /// Enable emotion-aware ("affective") dialog. Only honored by Gemini Live
476    /// native-audio models (v1alpha); a no-op for other providers/models.
477    pub fn with_affective_dialog(mut self, enabled: bool) -> Self {
478        self.affective_dialog = Some(enabled);
479        self
480    }
481
482    /// Pins the spoken language (BCP-47, e.g. `"en-US"`).
483    ///
484    /// Gemini Live sends it as `speechConfig.languageCode`, which steers both the voice and
485    /// the input/output transcription; without it the model detects the language per turn
486    /// and short or accented utterances can be transcribed in the wrong one. Gemini
487    /// native-audio output models choose the language automatically and do not honor it.
488    ///
489    /// Stored under `extra.language_code`. An `extra` value that is not a JSON object is
490    /// replaced. The OpenAI Realtime session copies every `extra` key into its
491    /// `session.update`, so set it only for a Gemini Live model.
492    ///
493    /// # Example
494    ///
495    /// ```
496    /// use adk_realtime::RealtimeConfig;
497    ///
498    /// let config = RealtimeConfig::default().with_voice("Kore").with_language("en-US");
499    /// assert_eq!(config.extra.unwrap()["language_code"], "en-US");
500    /// ```
501    pub fn with_language(self, code: impl Into<String>) -> Self {
502        self.with_extra("language_code", Value::String(code.into()))
503    }
504
505    /// Sets how much the Gemini Live model reasons, as `generationConfig.thinkingConfig`.
506    ///
507    /// [`Effort::Low`](adk_core::Effort::Low), `Medium` and `High` are sent as the thinking
508    /// levels `low`, `medium` and `high`. `gemini-3.8-live-extended-thinking` requires a
509    /// level (its server closes a setup without one with 1007), so ADK sends `medium` unless
510    /// you set one. `gemini-3.1-flash-live-preview` takes one. `gemini-3.8-live` reasons on
511    /// its own and closes the socket with 1007 on one, so it is not sent there.
512    ///
513    /// Stored under `extra.thinking_level`. An `extra` value that is not a JSON object is
514    /// replaced. The OpenAI Realtime session copies every `extra` key into its
515    /// `session.update`, so set it only for a Gemini Live model.
516    ///
517    /// # Example
518    ///
519    /// ```
520    /// use adk_core::Effort;
521    /// use adk_realtime::RealtimeConfig;
522    ///
523    /// let config = RealtimeConfig::default().with_thinking_level(Effort::Medium);
524    /// assert_eq!(config.extra.unwrap()["thinking_level"], "medium");
525    /// ```
526    pub fn with_thinking_level(self, effort: adk_core::Effort) -> Self {
527        self.with_extra("thinking_level", Value::String(effort.as_str().to_string()))
528    }
529
530    /// Turns on Gemini Live context window compression (a sliding window).
531    ///
532    /// The server drops the oldest turns once the context reaches `trigger_tokens` (default:
533    /// 80% of the model's context window). Google documents that without it a session ends
534    /// after about 15 minutes of audio, or about 2 once video frames are sent, and that with
535    /// it the session has no length limit (each connection still lasts about 10 minutes).
536    ///
537    /// Stored under `extra.context_window_compression`: `true`, or
538    /// `{"trigger_tokens": n}` when a threshold is given. The object form also accepts
539    /// `target_tokens`, the size to cut back to (default: half of `trigger_tokens`). An
540    /// `extra` value that is not a JSON object is replaced. The OpenAI Realtime session
541    /// copies every `extra` key into its `session.update`, so set it only for a Gemini Live
542    /// model.
543    ///
544    /// # Example
545    ///
546    /// ```
547    /// use adk_realtime::RealtimeConfig;
548    ///
549    /// let config = RealtimeConfig::default().with_context_window_compression(None);
550    /// assert_eq!(config.extra.unwrap()["context_window_compression"], true);
551    /// ```
552    pub fn with_context_window_compression(self, trigger_tokens: Option<u64>) -> Self {
553        let value = match trigger_tokens {
554            Some(tokens) => serde_json::json!({ "trigger_tokens": tokens }),
555            None => Value::Bool(true),
556        };
557        self.with_extra("context_window_compression", value)
558    }
559
560    /// Sets one key in `extra`, keeping the others; a non-object `extra` is replaced.
561    fn with_extra(mut self, key: &str, value: Value) -> Self {
562        let mut extra = match self.extra.take() {
563            Some(Value::Object(map)) => map,
564            _ => serde_json::Map::new(),
565        };
566        extra.insert(key.to_string(), value);
567        self.extra = Some(Value::Object(extra));
568        self
569    }
570
571    /// Set cached content resource.
572    pub fn with_cached_content(mut self, content: impl Into<String>) -> Self {
573        self.cached_content = Some(content.into());
574        self
575    }
576
577    /// Set the interruption detection mode.
578    ///
579    /// See [`InterruptionDetection`] for details on each variant.
580    pub fn with_interruption_detection(mut self, mode: InterruptionDetection) -> Self {
581        self.interruption_detection = Some(mode);
582        self
583    }
584
585    /// Enable automatic interruption detection.
586    ///
587    /// The session will detect user speech onset and cancel the current
588    /// agent audio output automatically.
589    pub fn with_automatic_interruption(self) -> Self {
590        self.with_interruption_detection(InterruptionDetection::Automatic)
591    }
592}
593
594/// Builder for RealtimeConfig.
595#[derive(Debug, Clone, Default)]
596pub struct RealtimeConfigBuilder {
597    config: RealtimeConfig,
598}
599
600impl RealtimeConfigBuilder {
601    /// Create a new builder.
602    pub fn new() -> Self {
603        Self::default()
604    }
605
606    /// Set the model.
607    pub fn model(mut self, model: impl Into<String>) -> Self {
608        self.config.model = Some(model.into());
609        self
610    }
611
612    /// Set the system instruction.
613    pub fn instruction(mut self, instruction: impl Into<String>) -> Self {
614        self.config.instruction = Some(instruction.into());
615        self
616    }
617
618    /// Set the voice.
619    pub fn voice(mut self, voice: impl Into<String>) -> Self {
620        self.config.voice = Some(voice.into());
621        self
622    }
623
624    /// Enable VAD.
625    pub fn vad_enabled(mut self, enabled: bool) -> Self {
626        if enabled {
627            self.config.turn_detection = Some(VadConfig::server_vad());
628        } else {
629            self.config.turn_detection = Some(VadConfig::disabled());
630        }
631        self
632    }
633
634    /// Set VAD configuration.
635    pub fn vad(mut self, vad: VadConfig) -> Self {
636        self.config.turn_detection = Some(vad);
637        self
638    }
639
640    /// Add a tool.
641    pub fn tool(mut self, tool: ToolDefinition) -> Self {
642        self.config.tools.get_or_insert_with(Vec::new).push(tool);
643        self
644    }
645
646    /// Set temperature.
647    pub fn temperature(mut self, temp: f32) -> Self {
648        self.config.temperature = Some(temp);
649        self
650    }
651
652    /// Set cached content resource.
653    pub fn cached_content(mut self, content: impl Into<String>) -> Self {
654        self.config.cached_content = Some(content.into());
655        self
656    }
657
658    /// Set the interruption detection mode.
659    pub fn interruption_detection(mut self, mode: InterruptionDetection) -> Self {
660        self.config.interruption_detection = Some(mode);
661        self
662    }
663
664    /// Build the configuration.
665    pub fn build(self) -> RealtimeConfig {
666        self.config
667    }
668}