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};

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct RealtimeConversationItemMessageAssistantContentInner {
    /// The content type, `output_text` or `output_audio` depending on the session `output_modalities` configuration.
    #[serde(rename = "type", skip_serializing_if = "Option::is_none")]
    pub r#type: Option<Type>,
    /// The text content.
    #[serde(rename = "text", skip_serializing_if = "Option::is_none")]
    pub text: Option<String>,
    /// Base64-encoded audio bytes, these will be parsed as the format specified in the session output audio type configuration. This defaults to PCM 16-bit 24kHz mono if not specified.
    #[serde(rename = "audio", skip_serializing_if = "Option::is_none")]
    pub audio: Option<String>,
    /// The transcript of the audio content, this will always be present if the output type is `audio`.
    #[serde(rename = "transcript", skip_serializing_if = "Option::is_none")]
    pub transcript: Option<String>,
}

impl RealtimeConversationItemMessageAssistantContentInner {
    pub fn new() -> RealtimeConversationItemMessageAssistantContentInner {
        RealtimeConversationItemMessageAssistantContentInner {
            r#type: None,
            text: None,
            audio: None,
            transcript: None,
        }
    }
}
/// The content type, `output_text` or `output_audio` depending on the session `output_modalities` configuration.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
    #[serde(rename = "output_text")]
    OutputText,
    #[serde(rename = "output_audio")]
    OutputAudio,
}

impl Default for Type {
    fn default() -> Type {
        Self::OutputText
    }
}

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