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

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct CompactResource {
    /// The unique identifier for the compacted response.
    #[serde(rename = "id")]
    pub id: String,
    /// The object type. Always `response.compaction`.
    #[serde(rename = "object")]
    pub object: Object,
    /// The compacted list of output items.
    #[serde(rename = "output")]
    pub output: Vec<models::ItemField>,
    /// Unix timestamp (in seconds) when the compacted conversation was created.
    #[serde(rename = "created_at")]
    pub created_at: i32,
    #[serde(rename = "usage")]
    pub usage: Box<models::ResponseUsage>,
}

impl CompactResource {
    pub fn new(
        id: String,
        object: Object,
        output: Vec<models::ItemField>,
        created_at: i32,
        usage: models::ResponseUsage,
    ) -> CompactResource {
        CompactResource {
            id,
            object,
            output,
            created_at,
            usage: Box::new(usage),
        }
    }
}
/// The object type. Always `response.compaction`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Object {
    #[serde(rename = "response.compaction")]
    ResponseCompaction,
}

impl Default for Object {
    fn default() -> Object {
        Self::ResponseCompaction
    }
}

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