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

/// RealtimeResponse : The response resource.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct RealtimeResponse {
    /// The unique ID of the response, will look like `resp_1234`.
    #[serde(rename = "id", skip_serializing_if = "Option::is_none")]
    pub id: Option<String>,
    /// The object type, must be `realtime.response`.
    #[serde(rename = "object", skip_serializing_if = "Option::is_none")]
    pub object: Option<Object>,
    /// The final status of the response (`completed`, `cancelled`, `failed`, or  `incomplete`, `in_progress`).
    #[serde(rename = "status", skip_serializing_if = "Option::is_none")]
    pub status: Option<Status>,
    #[serde(rename = "status_details", skip_serializing_if = "Option::is_none")]
    pub status_details: Option<Box<models::RealtimeResponseStatusDetails>>,
    /// The list of output items generated by the response.
    #[serde(rename = "output", skip_serializing_if = "Option::is_none")]
    pub output: Option<Vec<models::RealtimeConversationItem>>,
    /// Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard.  Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters.
    #[serde(
        rename = "metadata",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub metadata: Option<Option<std::collections::HashMap<String, String>>>,
    #[serde(rename = "audio", skip_serializing_if = "Option::is_none")]
    pub audio: Option<Box<models::RealtimeResponseAudio>>,
    #[serde(rename = "usage", skip_serializing_if = "Option::is_none")]
    pub usage: Option<Box<models::RealtimeResponseUsage>>,
    /// Which conversation the response is added to, determined by the `conversation` field in the `response.create` event. If `auto`, the response will be added to the default conversation and the value of `conversation_id` will be an id like `conv_1234`. If `none`, the response will not be added to any conversation and the value of `conversation_id` will be `null`. If responses are being triggered automatically by VAD the response will be added to the default conversation
    #[serde(rename = "conversation_id", skip_serializing_if = "Option::is_none")]
    pub conversation_id: Option<String>,
    /// The set of modalities the model used to respond, currently the only possible values are `[\\\"audio\\\"]`, `[\\\"text\\\"]`. Audio output always include a text transcript. Setting the output to mode `text` will disable audio output from the model.
    #[serde(rename = "output_modalities", skip_serializing_if = "Option::is_none")]
    pub output_modalities: Option<Vec<OutputModalities>>,
    #[serde(rename = "max_output_tokens", skip_serializing_if = "Option::is_none")]
    pub max_output_tokens: Option<Box<models::RealtimeBetaResponseMaxOutputTokens>>,
}

impl RealtimeResponse {
    /// The response resource.
    pub fn new() -> RealtimeResponse {
        RealtimeResponse {
            id: None,
            object: None,
            status: None,
            status_details: None,
            output: None,
            metadata: None,
            audio: None,
            usage: None,
            conversation_id: None,
            output_modalities: None,
            max_output_tokens: None,
        }
    }
}
/// The object type, must be `realtime.response`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Object {
    #[serde(rename = "realtime.response")]
    RealtimeResponse,
}

impl Default for Object {
    fn default() -> Object {
        Self::RealtimeResponse
    }
}
/// The final status of the response (`completed`, `cancelled`, `failed`, or  `incomplete`, `in_progress`).
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Status {
    #[serde(rename = "completed")]
    Completed,
    #[serde(rename = "cancelled")]
    Cancelled,
    #[serde(rename = "failed")]
    Failed,
    #[serde(rename = "incomplete")]
    Incomplete,
    #[serde(rename = "in_progress")]
    InProgress,
}

impl Default for Status {
    fn default() -> Status {
        Self::Completed
    }
}
/// The set of modalities the model used to respond, currently the only possible values are `[\\\"audio\\\"]`, `[\\\"text\\\"]`. Audio output always include a text transcript. Setting the output to mode `text` will disable audio output from the model.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum OutputModalities {
    #[serde(rename = "text")]
    Text,
    #[serde(rename = "audio")]
    Audio,
}

impl Default for OutputModalities {
    fn default() -> OutputModalities {
        Self::Text
    }
}

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