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

/// LiveInitialDeveloperMessageItemParam : A developer message included in the initial text history of a Live session.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct LiveInitialDeveloperMessageItemParam {
    /// An optional identifier for the supplied history message. Live uses the message’s role and text to initialize the conversation.
    #[serde(
        rename = "id",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub id: Option<Option<String>>,
    /// The history item type. Always `message`.
    #[serde(rename = "type", skip_serializing_if = "Option::is_none")]
    pub r#type: Option<Type>,
    #[serde(
        rename = "status",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub status: Option<Option<models::LiveInitialMessageStatus>>,
    /// The author of this history message. Always `developer`.
    #[serde(rename = "role")]
    pub role: Role,
    /// The message content. Supply exactly one text part for the initial Live conversation history.
    #[serde(rename = "content")]
    pub content: Vec<models::LiveInitialInputTextContentPartParam>,
}

impl LiveInitialDeveloperMessageItemParam {
    /// A developer message included in the initial text history of a Live session.
    pub fn new(
        role: Role,
        content: Vec<models::LiveInitialInputTextContentPartParam>,
    ) -> LiveInitialDeveloperMessageItemParam {
        LiveInitialDeveloperMessageItemParam {
            id: None,
            r#type: None,
            status: None,
            role,
            content,
        }
    }
}
/// The history item type. Always `message`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
    #[serde(rename = "message")]
    Message,
}

impl Default for Type {
    fn default() -> Type {
        Self::Message
    }
}
/// The author of this history message. Always `developer`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Role {
    #[serde(rename = "developer")]
    Developer,
}

impl Default for Role {
    fn default() -> Role {
        Self::Developer
    }
}

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