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

/// FunctionShellCallOutput : The output of a shell tool call that was emitted.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct FunctionShellCallOutput {
    /// The type of the shell call output. Always `shell_call_output`.
    #[serde(rename = "type")]
    pub r#type: Type,
    /// The unique ID of the shell call output. Populated when this item is returned via API.
    #[serde(rename = "id")]
    pub id: String,
    /// The unique ID of the shell tool call generated by the model.
    #[serde(rename = "call_id")]
    pub call_id: String,
    #[serde(rename = "status")]
    pub status: models::LocalShellCallOutputStatusEnum,
    /// An array of shell call output contents
    #[serde(rename = "output")]
    pub output: Vec<models::FunctionShellCallOutputContent>,
    /// The maximum length of the shell command output. This is generated by the model and should be passed back with the raw output.
    #[serde(rename = "max_output_length", deserialize_with = "Option::deserialize")]
    pub max_output_length: Option<i32>,
    /// 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 FunctionShellCallOutput {
    /// The output of a shell tool call that was emitted.
    pub fn new(
        r#type: Type,
        id: String,
        call_id: String,
        status: models::LocalShellCallOutputStatusEnum,
        output: Vec<models::FunctionShellCallOutputContent>,
        max_output_length: Option<i32>,
    ) -> FunctionShellCallOutput {
        FunctionShellCallOutput {
            r#type,
            id,
            call_id,
            status,
            output,
            max_output_length,
            created_by: None,
        }
    }
}
/// The type of the shell call output. Always `shell_call_output`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
    #[serde(rename = "shell_call_output")]
    ShellCallOutput,
}

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

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