/*
* OpenAI API
*
* The OpenAI REST API. Please see https://platform.openai.com/docs/api-reference for more details.
*
* The version of the OpenAPI document: 2.3.0
*
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
/// RealtimeBetaClientEventSessionUpdate : Send this event to update the session’s default configuration. The client may send this event at any time to update any field, except for `voice`. However, note that once a session has been initialized with a particular `model`, it can’t be changed to another model using `session.update`. When the server receives a `session.update`, it will respond with a `session.updated` event showing the full, effective configuration. Only the fields that are present are updated. To clear a field like `instructions`, pass an empty string.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct RealtimeBetaClientEventSessionUpdate {
/// Optional client-generated ID used to identify this event.
#[serde(rename = "event_id", skip_serializing_if = "Option::is_none")]
pub event_id: Option<String>,
/// The event type, must be `session.update`.
#[serde(rename = "type")]
pub r#type: Type,
#[serde(rename = "session")]
pub session: Box<models::RealtimeSessionCreateRequest>,
}
impl RealtimeBetaClientEventSessionUpdate {
/// Send this event to update the session’s default configuration. The client may send this event at any time to update any field, except for `voice`. However, note that once a session has been initialized with a particular `model`, it can’t be changed to another model using `session.update`. When the server receives a `session.update`, it will respond with a `session.updated` event showing the full, effective configuration. Only the fields that are present are updated. To clear a field like `instructions`, pass an empty string.
pub fn new(
r#type: Type,
session: models::RealtimeSessionCreateRequest,
) -> RealtimeBetaClientEventSessionUpdate {
RealtimeBetaClientEventSessionUpdate {
event_id: None,
r#type,
session: Box::new(session),
}
}
}
/// The event type, must be `session.update`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
#[serde(rename = "session.update")]
SessionUpdate,
}
impl Default for Type {
fn default() -> Type {
Self::SessionUpdate
}
}
impl std::fmt::Display for RealtimeBetaClientEventSessionUpdate {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match serde_json::to_string(self) {
Ok(s) => write!(f, "{}", s),
Err(_) => Err(std::fmt::Error),
}
}
}