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

/// ComputerToolCall : A tool call to a computer use tool. See the [computer use guide](/docs/guides/tools-computer-use) for more information.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct ComputerToolCall {
    /// The type of the computer call. Always `computer_call`.
    #[serde(rename = "type")]
    pub r#type: Type,
    /// The unique ID of the computer call.
    #[serde(rename = "id")]
    pub id: String,
    /// An identifier used when responding to the tool call with output.
    #[serde(rename = "call_id")]
    pub call_id: String,
    #[serde(rename = "action", skip_serializing_if = "Option::is_none")]
    pub action: Option<serde_json::Value>,
    /// Flattened batched actions for `computer_use`. Each action includes an `type` discriminator and action-specific fields.
    #[serde(rename = "actions", skip_serializing_if = "Option::is_none")]
    pub actions: Option<Vec<serde_json::Value>>,
    /// The pending safety checks for the computer call.
    #[serde(rename = "pending_safety_checks")]
    pub pending_safety_checks: Vec<models::ComputerCallSafetyCheckParam>,
    /// The status of the item. One of `in_progress`, `completed`, or `incomplete`. Populated when items are returned via API.
    #[serde(rename = "status")]
    pub status: Status,
}

impl ComputerToolCall {
    /// A tool call to a computer use tool. See the [computer use guide](/docs/guides/tools-computer-use) for more information.
    pub fn new(
        r#type: Type,
        id: String,
        call_id: String,
        pending_safety_checks: Vec<models::ComputerCallSafetyCheckParam>,
        status: Status,
    ) -> ComputerToolCall {
        ComputerToolCall {
            r#type,
            id,
            call_id,
            action: None,
            actions: None,
            pending_safety_checks,
            status,
        }
    }
}
/// The type of the computer call. Always `computer_call`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
    #[serde(rename = "computer_call")]
    ComputerCall,
}

impl Default for Type {
    fn default() -> Type {
        Self::ComputerCall
    }
}
/// The status of the item. One of `in_progress`, `completed`, or `incomplete`. Populated when items are returned via API.
#[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,
}

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

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