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 FunctionToolCallOutputResource {
    /// The unique ID of the function call tool output.
    #[serde(rename = "id")]
    pub id: String,
    /// The type of the function tool call output. Always `function_call_output`.
    #[serde(rename = "type")]
    pub r#type: Type,
    /// The unique ID of the function tool call generated by the model.
    #[serde(rename = "call_id")]
    pub call_id: String,
    #[serde(rename = "output")]
    pub output: Box<models::FunctionToolCallOutputOutput>,
    #[serde(rename = "status")]
    pub status: models::FunctionCallOutputStatusEnum,
    /// The identifier of the actor that created the item.
    #[serde(rename = "created_by", skip_serializing_if = "Option::is_none")]
    pub created_by: Option<String>,
}

impl FunctionToolCallOutputResource {
    pub fn new(
        id: String,
        r#type: Type,
        call_id: String,
        output: models::FunctionToolCallOutputOutput,
        status: models::FunctionCallOutputStatusEnum,
    ) -> FunctionToolCallOutputResource {
        FunctionToolCallOutputResource {
            id,
            r#type,
            call_id,
            output: Box::new(output),
            status,
            created_by: 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 FunctionToolCallOutputResource {
    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),
        }
    }
}