openai-client-base 0.16.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};

/// ComputerUseCallItemResource : One execution of the platform-provided computer-use capability.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct ComputerUseCallItemResource {
    /// The item type. Always `computer_use_call`.
    #[serde(rename = "type")]
    pub r#type: Type,
    /// The ID of the activity item.
    #[serde(rename = "id")]
    pub id: String,
    /// The ID of the turn that contains this item.
    #[serde(rename = "turn_id")]
    pub turn_id: String,
    /// A model-generated description of the activity, when available.
    #[serde(rename = "title", deserialize_with = "Option::deserialize")]
    pub title: Option<String>,
    #[serde(rename = "status")]
    pub status: models::FunctionCallStatusResource,
    #[serde(rename = "output", deserialize_with = "Option::deserialize")]
    pub output: Option<models::ComputerScreenshotResource>,
}

impl ComputerUseCallItemResource {
    /// One execution of the platform-provided computer-use capability.
    pub fn new(
        r#type: Type,
        id: String,
        turn_id: String,
        title: Option<String>,
        status: models::FunctionCallStatusResource,
        output: Option<models::ComputerScreenshotResource>,
    ) -> ComputerUseCallItemResource {
        ComputerUseCallItemResource {
            r#type,
            id,
            turn_id,
            title,
            status,
            output,
        }
    }
}
/// The item type. Always `computer_use_call`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
    #[serde(rename = "computer_use_call")]
    ComputerUseCall,
}

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

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