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

/// FunctionShellCall : A tool call that executes one or more shell commands in a managed environment.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct FunctionShellCall {
    /// The type of the item. Always `shell_call`.
    #[serde(rename = "type")]
    pub r#type: Type,
    /// The unique ID of the shell tool call. 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 = "action")]
    pub action: Box<models::FunctionShellAction>,
    #[serde(rename = "status")]
    pub status: models::LocalShellCallStatus,
    #[serde(rename = "environment", deserialize_with = "Option::deserialize")]
    pub environment: Option<Box<models::FunctionShellCallEnvironment>>,
    /// The ID of the entity that created this tool call.
    #[serde(rename = "created_by", skip_serializing_if = "Option::is_none")]
    pub created_by: Option<String>,
}

impl FunctionShellCall {
    /// A tool call that executes one or more shell commands in a managed environment.
    pub fn new(
        r#type: Type,
        id: String,
        call_id: String,
        action: models::FunctionShellAction,
        status: models::LocalShellCallStatus,
        environment: Option<models::FunctionShellCallEnvironment>,
    ) -> FunctionShellCall {
        FunctionShellCall {
            r#type,
            id,
            call_id,
            action: Box::new(action),
            status,
            environment: environment.map(Box::new),
            created_by: None,
        }
    }
}
/// The type of the item. Always `shell_call`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
    #[serde(rename = "shell_call")]
    ShellCall,
}

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

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