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

/// ImageGenTool : A tool that generates images using the GPT image models.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct ImageGenTool {
    /// The type of the image generation tool. Always `image_generation`.
    #[serde(rename = "type")]
    pub r#type: Type,
    /// ID of the model to use
    #[serde(rename = "model", skip_serializing_if = "Option::is_none")]
    pub model: Option<String>,
    /// The quality of the generated image. One of `low`, `medium`, `high`, or `auto`. Default: `auto`.
    #[serde(rename = "quality", skip_serializing_if = "Option::is_none")]
    pub quality: Option<Quality>,
    /// The size of the generated image. One of `1024x1024`, `1024x1536`, `1536x1024`, or `auto`. Default: `auto`.
    #[serde(rename = "size", skip_serializing_if = "Option::is_none")]
    pub size: Option<Size>,
    /// The output format of the generated image. One of `png`, `webp`, or `jpeg`. Default: `png`.
    #[serde(rename = "output_format", skip_serializing_if = "Option::is_none")]
    pub output_format: Option<OutputFormat>,
    /// Compression level for the output image. Default: 100.
    #[serde(rename = "output_compression", skip_serializing_if = "Option::is_none")]
    pub output_compression: Option<i32>,
    /// Moderation level for the generated image. Default: `auto`.
    #[serde(rename = "moderation", skip_serializing_if = "Option::is_none")]
    pub moderation: Option<Moderation>,
    /// Background type for the generated image. One of `transparent`, `opaque`, or `auto`. Default: `auto`.
    #[serde(rename = "background", skip_serializing_if = "Option::is_none")]
    pub background: Option<Background>,
    #[serde(
        rename = "input_fidelity",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub input_fidelity: Option<Option<models::InputFidelity>>,
    #[serde(rename = "input_image_mask", skip_serializing_if = "Option::is_none")]
    pub input_image_mask: Option<models::ImageGenToolInputImageMask>,
    /// Number of partial images to generate in streaming mode, from 0 (default value) to 3.
    #[serde(rename = "partial_images", skip_serializing_if = "Option::is_none")]
    pub partial_images: Option<i32>,
    #[serde(rename = "action", skip_serializing_if = "Option::is_none")]
    pub action: Option<models::ImageGenActionEnum>,
}

impl ImageGenTool {
    /// A tool that generates images using the GPT image models.
    pub fn new(r#type: Type) -> ImageGenTool {
        ImageGenTool {
            r#type,
            model: None,
            quality: None,
            size: None,
            output_format: None,
            output_compression: None,
            moderation: None,
            background: None,
            input_fidelity: None,
            input_image_mask: None,
            partial_images: None,
            action: None,
        }
    }
}
/// The type of the image generation tool. Always `image_generation`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
    #[serde(rename = "image_generation")]
    ImageGeneration,
}

impl Default for Type {
    fn default() -> Type {
        Self::ImageGeneration
    }
}
/// The quality of the generated image. One of `low`, `medium`, `high`, or `auto`. Default: `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 = "auto")]
    Auto,
}

impl Default for Quality {
    fn default() -> Quality {
        Self::Low
    }
}
/// The size of the generated image. One of `1024x1024`, `1024x1536`, `1536x1024`, or `auto`. Default: `auto`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Size {
    #[serde(rename = "1024x1024")]
    Variant1024x1024,
    #[serde(rename = "1024x1536")]
    Variant1024x1536,
    #[serde(rename = "1536x1024")]
    Variant1536x1024,
    #[serde(rename = "auto")]
    Auto,
}

impl Default for Size {
    fn default() -> Size {
        Self::Variant1024x1024
    }
}
/// The output format of the generated image. One of `png`, `webp`, or `jpeg`. Default: `png`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum OutputFormat {
    #[serde(rename = "png")]
    Png,
    #[serde(rename = "webp")]
    Webp,
    #[serde(rename = "jpeg")]
    Jpeg,
}

impl Default for OutputFormat {
    fn default() -> OutputFormat {
        Self::Png
    }
}
/// Moderation level for the generated image. Default: `auto`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Moderation {
    #[serde(rename = "auto")]
    Auto,
    #[serde(rename = "low")]
    Low,
}

impl Default for Moderation {
    fn default() -> Moderation {
        Self::Auto
    }
}
/// Background type for the generated image. One of `transparent`, `opaque`, or `auto`. Default: `auto`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Background {
    #[serde(rename = "transparent")]
    Transparent,
    #[serde(rename = "opaque")]
    Opaque,
    #[serde(rename = "auto")]
    Auto,
}

impl Default for Background {
    fn default() -> Background {
        Self::Transparent
    }
}

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