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

/// BetaImageGenToolCall : An image generation request made by the model.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct BetaImageGenToolCall {
    #[serde(
        rename = "agent",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub agent: Option<Option<Box<models::BetaAgentTag>>>,
    /// The type of the image generation call. Always `image_generation_call`.
    #[serde(rename = "type")]
    pub r#type: Type,
    /// The unique ID of the image generation call.
    #[serde(rename = "id")]
    pub id: String,
    /// The status of the image generation call.
    #[serde(rename = "status")]
    pub status: Status,
    /// The generated image encoded in base64.
    #[serde(rename = "result", deserialize_with = "Option::deserialize")]
    pub result: Option<String>,
    #[serde(rename = "error", skip_serializing_if = "Option::is_none")]
    pub error: Option<Box<models::BetaImageGenToolCallError>>,
    #[serde(
        rename = "size",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub size: Option<Option<Box<models::ImageGenToolCallSize>>>,
    /// The quality of the image generated by the image generation tool call. One of `low`, `medium`, `high`, `xhigh`, `max`, or `auto`.
    #[serde(
        rename = "quality",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub quality: Option<Option<Quality>>,
    #[serde(
        rename = "action",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub action: Option<Option<models::BetaImageGenActionEnum>>,
    #[serde(
        rename = "background",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub background: Option<Option<models::BetaImageBackground>>,
    #[serde(
        rename = "output_format",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub output_format: Option<Option<models::BetaImageOutputFormat>>,
    /// The prompt that was used after any model prompt rewriting.
    #[serde(
        rename = "revised_prompt",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub revised_prompt: Option<Option<String>>,
}

impl BetaImageGenToolCall {
    /// An image generation request made by the model.
    pub fn new(
        r#type: Type,
        id: String,
        status: Status,
        result: Option<String>,
    ) -> BetaImageGenToolCall {
        BetaImageGenToolCall {
            agent: None,
            r#type,
            id,
            status,
            result,
            error: None,
            size: None,
            quality: None,
            action: None,
            background: None,
            output_format: None,
            revised_prompt: None,
        }
    }
}
/// The type of the image generation call. Always `image_generation_call`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
    #[serde(rename = "image_generation_call")]
    ImageGenerationCall,
}

impl Default for Type {
    fn default() -> Type {
        Self::ImageGenerationCall
    }
}
/// The status of the image generation call.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Status {
    #[serde(rename = "in_progress")]
    InProgress,
    #[serde(rename = "completed")]
    Completed,
    #[serde(rename = "generating")]
    Generating,
    #[serde(rename = "failed")]
    Failed,
}

impl Default for Status {
    fn default() -> Status {
        Self::InProgress
    }
}
/// The quality of the image generated by the image generation tool call. One of `low`, `medium`, `high`, `xhigh`, `max`, or `auto`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Quality {
    #[serde(rename = "low")]
    Low,
    #[serde(rename = "medium")]
    Medium,
    #[serde(rename = "high")]
    High,
    #[serde(rename = "xhigh")]
    Xhigh,
    #[serde(rename = "max")]
    Max,
    #[serde(rename = "auto")]
    Auto,
}

impl Default for Quality {
    fn default() -> Quality {
        Self::Low
    }
}

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