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

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct BetaFunctionToolParam {
    #[serde(rename = "name")]
    pub name: String,
    #[serde(
        rename = "description",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub description: Option<Option<String>>,
    #[serde(rename = "parameters", skip_serializing_if = "Option::is_none")]
    pub parameters: Option<serde_json::Value>,
    /// Whether to enforce strict parameter validation. If omitted, Responses attempts to use strict validation when the schema is compatible, and falls back to non-strict validation otherwise.
    #[serde(
        rename = "strict",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub strict: Option<Option<bool>>,
    #[serde(rename = "type")]
    pub r#type: Type,
    /// Whether the tool response can be returned asynchronously versus immediately returned on next response creation.
    #[serde(rename = "async", skip_serializing_if = "Option::is_none")]
    pub r#async: Option<bool>,
    /// A JSON Schema describing the JSON value encoded in string outputs for this function tool. This does not describe content-array outputs.
    #[serde(
        rename = "output_schema",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub output_schema: Option<Option<std::collections::HashMap<String, serde_json::Value>>>,
    /// Whether this function should be deferred and discovered via tool search.
    #[serde(rename = "defer_loading", skip_serializing_if = "Option::is_none")]
    pub defer_loading: Option<bool>,
    /// The tool invocation context(s).
    #[serde(
        rename = "allowed_callers",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub allowed_callers: Option<Option<Vec<models::BetaCallableToolAllowedCaller>>>,
}

impl BetaFunctionToolParam {
    pub fn new(name: String, r#type: Type) -> BetaFunctionToolParam {
        BetaFunctionToolParam {
            name,
            description: None,
            parameters: None,
            strict: None,
            r#type,
            r#async: None,
            output_schema: None,
            defer_loading: None,
            allowed_callers: None,
        }
    }
}
///
#[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 BetaFunctionToolParam {
    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),
        }
    }
}