openai-client-base 0.16.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};

/// SessionInputParamAgentSessionInputToolResult : Submits the result of a function call.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct SessionInputParamAgentSessionInputToolResult {
    /// The type of the object. Always `agent.session.input.tool_result`.
    #[serde(rename = "type")]
    pub r#type: Type,
    /// The ID of the turn that requested the function call.
    #[serde(rename = "turn_id")]
    pub turn_id: String,
    /// The ID of the function call.
    #[serde(rename = "call_id")]
    pub call_id: String,
    /// Whether the function call succeeded.
    #[serde(rename = "success")]
    pub success: bool,
    #[serde(
        rename = "output",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub output: Option<Option<Box<models::FunctionCallOutputParam>>>,
    /// The error message when the call failed.
    #[serde(
        rename = "error",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub error: Option<Option<String>>,
}

impl SessionInputParamAgentSessionInputToolResult {
    /// Submits the result of a function call.
    pub fn new(
        r#type: Type,
        turn_id: String,
        call_id: String,
        success: bool,
    ) -> SessionInputParamAgentSessionInputToolResult {
        SessionInputParamAgentSessionInputToolResult {
            r#type,
            turn_id,
            call_id,
            success,
            output: None,
            error: None,
        }
    }
}
/// The type of the object. Always `agent.session.input.tool_result`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
    #[serde(rename = "agent.session.input.tool_result")]
    AgentSessionInputToolResult,
}

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

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