openai-client-base 0.16.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};

/// LiveSessionResourceParam : The resolved Live session configuration and server-assigned session metadata.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct LiveSessionResourceParam {
    #[serde(rename = "model")]
    pub model: Box<models::ModelIdsLive>,
    /// Frontend instructions for voice, conversation, interruptions, and when to delegate. Start with the [Live prompting guide](https://developers.openai.com/api/docs/guides/live-prompting); put business rules and tool workflows in a separate [backend prompt](https://developers.openai.com/api/docs/guides/live-delegation#start-with-your-existing-backend-prompt). Limited to 16,384 client-supplied tokens. Omitted or blank instructions use server defaults. Immutable after startup.
    #[serde(
        rename = "instructions",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub instructions: Option<Option<String>>,
    /// Ordered text-only history supplied before startup. Supports developer, user, and assistant messages with one text part each; at most 128 messages and a configured rendered-token limit (8,192 by default).
    #[serde(rename = "input", skip_serializing_if = "Option::is_none")]
    pub input: Option<Vec<models::LiveInitialItem>>,
    #[serde(rename = "audio", skip_serializing_if = "Option::is_none")]
    pub audio: Option<Box<models::LiveInitialSessionAudioParam>>,
    #[serde(
        rename = "delegation",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub delegation: Option<Option<Box<models::LiveSessionCreateParamsDelegation>>>,
    /// At most one Decisions trigger per transcript event type. Triggers run independently of delegation. On update, omit triggers to keep the current configuration, send a list to replace it, or send an empty list to disable triggers.
    #[serde(rename = "triggers", skip_serializing_if = "Option::is_none")]
    pub triggers: Option<Vec<models::LiveDecisionTriggerInputParam2>>,
    /// Whether to store the session for later forking and recording download. Defaults to false for new sessions.
    #[serde(rename = "store", skip_serializing_if = "Option::is_none")]
    pub store: Option<bool>,
    #[serde(rename = "client", skip_serializing_if = "Option::is_none")]
    pub client: Option<Box<models::LiveClientConfigParam>>,
    /// The unique ID of the Live session. Use this ID for sideband connections, forking, and recording download.
    #[serde(rename = "id")]
    pub id: String,
    /// The Unix timestamp, in seconds, at which the Live session expires.
    #[serde(rename = "expires_at")]
    pub expires_at: i32,
    /// The status of the session snapshot. Always `active`, including the final snapshot in session.closed; use the event type to determine that the session has closed.
    #[serde(rename = "status")]
    pub status: Status,
}

impl LiveSessionResourceParam {
    /// The resolved Live session configuration and server-assigned session metadata.
    pub fn new(
        model: models::ModelIdsLive,
        id: String,
        expires_at: i32,
        status: Status,
    ) -> LiveSessionResourceParam {
        LiveSessionResourceParam {
            model: Box::new(model),
            instructions: None,
            input: None,
            audio: None,
            delegation: None,
            triggers: None,
            store: None,
            client: None,
            id,
            expires_at,
            status,
        }
    }
}
/// The status of the session snapshot. Always `active`, including the final snapshot in session.closed; use the event type to determine that the session has closed.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Status {
    #[serde(rename = "active")]
    Active,
}

impl Default for Status {
    fn default() -> Status {
        Self::Active
    }
}

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