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

/// FunctionCallOutputItemParam : The output of a function tool call.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct FunctionCallOutputItemParam {
    /// The unique ID of the function tool call output. Populated when this item is returned via API.
    #[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 function tool call generated by the model.
    #[serde(rename = "call_id")]
    pub call_id: String,
    /// The type of the function tool call output. Always `function_call_output`.
    #[serde(rename = "type")]
    pub r#type: Type,
    #[serde(rename = "output")]
    pub output: Box<models::FunctionCallOutputItemParamOutput>,
    #[serde(
        rename = "status",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub status: Option<Option<models::FunctionCallItemStatus>>,
}

impl FunctionCallOutputItemParam {
    /// The output of a function tool call.
    pub fn new(
        call_id: String,
        r#type: Type,
        output: models::FunctionCallOutputItemParamOutput,
    ) -> FunctionCallOutputItemParam {
        FunctionCallOutputItemParam {
            id: None,
            call_id,
            r#type,
            output: Box::new(output),
            status: None,
        }
    }
}
/// The type of the function tool call output. Always `function_call_output`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
    #[serde(rename = "function_call_output")]
    FunctionCallOutput,
}

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

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