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 FunctionToolCallResource {
    /// The unique ID of the function tool call.
    #[serde(rename = "id")]
    pub id: String,
    /// The type of the function tool call. Always `function_call`.
    #[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,
    /// The namespace of the function to run.
    #[serde(rename = "namespace", skip_serializing_if = "Option::is_none")]
    pub namespace: Option<String>,
    /// The name of the function to run.
    #[serde(rename = "name")]
    pub name: String,
    /// A JSON string of the arguments to pass to the function.
    #[serde(rename = "arguments")]
    pub arguments: String,
    #[serde(rename = "status")]
    pub status: models::FunctionCallStatus,
    /// 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 FunctionToolCallResource {
    pub fn new(
        id: String,
        r#type: Type,
        call_id: String,
        name: String,
        arguments: String,
        status: models::FunctionCallStatus,
    ) -> FunctionToolCallResource {
        FunctionToolCallResource {
            id,
            r#type,
            call_id,
            namespace: None,
            name,
            arguments,
            status,
            created_by: None,
        }
    }
}
/// The type of the function tool call. Always `function_call`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
    #[serde(rename = "function_call")]
    FunctionCall,
}

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

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