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

/// McpToolCall : An invocation of a tool on an MCP server.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct McpToolCall {
    /// The type of the item. Always `mcp_call`.
    #[serde(rename = "type")]
    pub r#type: Type,
    /// The unique ID of the tool call.
    #[serde(rename = "id")]
    pub id: String,
    /// The label of the MCP server running the tool.
    #[serde(rename = "server_label")]
    pub server_label: String,
    /// The name of the tool that was run.
    #[serde(rename = "name")]
    pub name: String,
    /// A JSON string of the arguments passed to the tool.
    #[serde(rename = "arguments")]
    pub arguments: String,
    /// The output from the tool call.
    #[serde(
        rename = "output",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub output: Option<Option<String>>,
    /// The error from the tool call, if any.
    #[serde(
        rename = "error",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub error: Option<Option<String>>,
    #[serde(rename = "status", skip_serializing_if = "Option::is_none")]
    pub status: Option<models::McpToolCallStatus>,
    /// Unique identifier for the MCP tool call approval request. Include this value in a subsequent `mcp_approval_response` input to approve or reject the corresponding tool call.
    #[serde(
        rename = "approval_request_id",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub approval_request_id: Option<Option<String>>,
}

impl McpToolCall {
    /// An invocation of a tool on an MCP server.
    pub fn new(
        r#type: Type,
        id: String,
        server_label: String,
        name: String,
        arguments: String,
    ) -> McpToolCall {
        McpToolCall {
            r#type,
            id,
            server_label,
            name,
            arguments,
            output: None,
            error: None,
            status: None,
            approval_request_id: None,
        }
    }
}
/// The type of the item. Always `mcp_call`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
    #[serde(rename = "mcp_call")]
    McpCall,
}

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

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