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

/// CodeInterpreterToolCall : A tool call to run code.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct CodeInterpreterToolCall {
    /// The type of the code interpreter tool call. Always `code_interpreter_call`.
    #[serde(rename = "type")]
    pub r#type: Type,
    /// The unique ID of the code interpreter tool call.
    #[serde(rename = "id")]
    pub id: String,
    /// The status of the code interpreter tool call. Valid values are `in_progress`, `completed`, `incomplete`, `interpreting`, and `failed`.
    #[serde(rename = "status")]
    pub status: Status,
    /// The ID of the container used to run the code.
    #[serde(rename = "container_id")]
    pub container_id: String,
    /// The code to run, or null if not available.
    #[serde(rename = "code", deserialize_with = "Option::deserialize")]
    pub code: Option<String>,
    /// The outputs generated by the code interpreter, such as logs or images. Can be null if no outputs are available.
    #[serde(rename = "outputs", deserialize_with = "Option::deserialize")]
    pub outputs: Option<Vec<models::CodeInterpreterToolCallOutputsInner>>,
}

impl CodeInterpreterToolCall {
    /// A tool call to run code.
    pub fn new(
        r#type: Type,
        id: String,
        status: Status,
        container_id: String,
        code: Option<String>,
        outputs: Option<Vec<models::CodeInterpreterToolCallOutputsInner>>,
    ) -> CodeInterpreterToolCall {
        CodeInterpreterToolCall {
            r#type,
            id,
            status,
            container_id,
            code,
            outputs,
        }
    }
}
/// The type of the code interpreter tool call. Always `code_interpreter_call`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
    #[serde(rename = "code_interpreter_call")]
    CodeInterpreterCall,
}

impl Default for Type {
    fn default() -> Type {
        Self::CodeInterpreterCall
    }
}
/// The status of the code interpreter tool call. Valid values are `in_progress`, `completed`, `incomplete`, `interpreting`, and `failed`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Status {
    #[serde(rename = "in_progress")]
    InProgress,
    #[serde(rename = "completed")]
    Completed,
    #[serde(rename = "incomplete")]
    Incomplete,
    #[serde(rename = "interpreting")]
    Interpreting,
    #[serde(rename = "failed")]
    Failed,
}

impl Default for Status {
    fn default() -> Status {
        Self::InProgress
    }
}

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