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

/// FunctionShellCallOutputItemParam : The streamed output items emitted by a shell tool call.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct FunctionShellCallOutputItemParam {
    /// The unique ID of the shell tool call output. Populated when this item is returned via API.
    #[serde(
        rename = "id",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub id: Option<Option<String>>,
    /// The unique ID of the shell tool call generated by the model.
    #[serde(rename = "call_id")]
    pub call_id: String,
    /// The type of the item. Always `shell_call_output`.
    #[serde(rename = "type")]
    pub r#type: Type,
    /// Captured chunks of stdout and stderr output, along with their associated outcomes.
    #[serde(rename = "output")]
    pub output: Vec<models::FunctionShellCallOutputContentParam>,
    #[serde(
        rename = "status",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub status: Option<Option<models::FunctionShellCallItemStatus>>,
    /// The maximum number of UTF-8 characters captured for this shell call's combined output.
    #[serde(
        rename = "max_output_length",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub max_output_length: Option<Option<i32>>,
}

impl FunctionShellCallOutputItemParam {
    /// The streamed output items emitted by a shell tool call.
    pub fn new(
        call_id: String,
        r#type: Type,
        output: Vec<models::FunctionShellCallOutputContentParam>,
    ) -> FunctionShellCallOutputItemParam {
        FunctionShellCallOutputItemParam {
            id: None,
            call_id,
            r#type,
            output,
            status: None,
            max_output_length: None,
        }
    }
}
/// The type of the item. 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 FunctionShellCallOutputItemParam {
    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),
        }
    }
}