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

/// LiveFunctionToolInputParam : A function tool available to the Responses backend when the Live model delegates a task.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct LiveFunctionToolInputParam {
    /// The tool type. Always `function`.
    #[serde(rename = "type")]
    pub r#type: Type,
    /// The name the delegated Responses model uses when calling this function.
    #[serde(rename = "name")]
    pub name: String,
    /// What the function does and when the delegated Responses model should call it.
    #[serde(
        rename = "description",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub description: Option<Option<String>>,
    /// A JSON Schema object describing the arguments accepted by the function.
    #[serde(
        rename = "parameters",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub parameters: Option<Option<std::collections::HashMap<String, serde_json::Value>>>,
    /// Whether the delegated Responses model must follow the function’s parameter schema exactly.
    #[serde(
        rename = "strict",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub strict: Option<Option<bool>>,
}

impl LiveFunctionToolInputParam {
    /// A function tool available to the Responses backend when the Live model delegates a task.
    pub fn new(r#type: Type, name: String) -> LiveFunctionToolInputParam {
        LiveFunctionToolInputParam {
            r#type,
            name,
            description: None,
            parameters: None,
            strict: None,
        }
    }
}
/// The tool type. Always `function`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
    #[serde(rename = "function")]
    Function,
}

impl Default for Type {
    fn default() -> Type {
        Self::Function
    }
}

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