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

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct ToolSearchCallItemParam {
    /// The unique ID of this tool search call.
    #[serde(
        rename = "id",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub id: Option<Option<String>>,
    /// The unique ID of the tool search call generated by the model.
    #[serde(
        rename = "call_id",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub call_id: Option<Option<String>>,
    /// The item type. Always `tool_search_call`.
    #[serde(rename = "type")]
    pub r#type: Type,
    #[serde(rename = "execution", skip_serializing_if = "Option::is_none")]
    pub execution: Option<models::ToolSearchExecutionType>,
    #[serde(rename = "arguments")]
    pub arguments: serde_json::Value,
    #[serde(
        rename = "status",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub status: Option<Option<models::FunctionCallItemStatus>>,
}

impl ToolSearchCallItemParam {
    pub fn new(r#type: Type, arguments: serde_json::Value) -> ToolSearchCallItemParam {
        ToolSearchCallItemParam {
            id: None,
            call_id: None,
            r#type,
            execution: None,
            arguments,
            status: None,
        }
    }
}
/// The item type. Always `tool_search_call`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
    #[serde(rename = "tool_search_call")]
    ToolSearchCall,
}

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

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