openai-client-base 0.12.0

Auto-generated Rust client for the OpenAI API
/*
 * 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};

/// RealtimeTranscriptionSessionCreateResponse : A new Realtime transcription session configuration.  When a session is created on the server via REST API, the session object also contains an ephemeral key. Default TTL for keys is 10 minutes. This property is not present when a session is updated via the WebSocket API.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct RealtimeTranscriptionSessionCreateResponse {
    #[serde(rename = "client_secret")]
    pub client_secret: Box<models::RealtimeTranscriptionSessionCreateResponseClientSecret>,
    #[serde(
        rename = "modalities",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub modalities: Option<Option<serde_json::Value>>,
    /// The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`.
    #[serde(rename = "input_audio_format", skip_serializing_if = "Option::is_none")]
    pub input_audio_format: Option<String>,
    #[serde(
        rename = "input_audio_transcription",
        skip_serializing_if = "Option::is_none"
    )]
    pub input_audio_transcription: Option<Box<models::AudioTranscription>>,
    #[serde(rename = "turn_detection", skip_serializing_if = "Option::is_none")]
    pub turn_detection: Option<Box<models::RealtimeSessionCreateRequestTurnDetection>>,
}

impl RealtimeTranscriptionSessionCreateResponse {
    /// A new Realtime transcription session configuration.  When a session is created on the server via REST API, the session object also contains an ephemeral key. Default TTL for keys is 10 minutes. This property is not present when a session is updated via the WebSocket API.
    pub fn new(
        client_secret: models::RealtimeTranscriptionSessionCreateResponseClientSecret,
    ) -> RealtimeTranscriptionSessionCreateResponse {
        RealtimeTranscriptionSessionCreateResponse {
            client_secret: Box::new(client_secret),
            modalities: None,
            input_audio_format: None,
            input_audio_transcription: None,
            turn_detection: None,
        }
    }
}

impl std::fmt::Display for RealtimeTranscriptionSessionCreateResponse {
    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),
        }
    }
}