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

/// ChatCompletionMessageToolCallFunction : The function that the model called.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct ChatCompletionMessageToolCallFunction {
    /// The name of the function to call.
    #[serde(rename = "name")]
    pub name: String,
    /// The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function.
    #[serde(rename = "arguments")]
    pub arguments: String,
}

impl ChatCompletionMessageToolCallFunction {
    /// The function that the model called.
    pub fn new(name: String, arguments: String) -> ChatCompletionMessageToolCallFunction {
        ChatCompletionMessageToolCallFunction { name, arguments }
    }
}

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