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

/// UsageEmbeddingsResult : The aggregated embeddings usage details of the specific time bucket.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct UsageEmbeddingsResult {
    #[serde(rename = "object")]
    pub object: Object,
    /// The aggregated number of input tokens used.
    #[serde(rename = "input_tokens")]
    pub input_tokens: i32,
    /// The count of requests made to the model.
    #[serde(rename = "num_model_requests")]
    pub num_model_requests: i32,
    /// When `group_by=project_id`, this field provides the project ID of the grouped usage result.
    #[serde(
        rename = "project_id",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub project_id: Option<Option<String>>,
    /// When `group_by=user_id`, this field provides the user ID of the grouped usage result.
    #[serde(
        rename = "user_id",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub user_id: Option<Option<String>>,
    /// When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result.
    #[serde(
        rename = "api_key_id",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub api_key_id: Option<Option<String>>,
    /// ID of the model to use
    #[serde(rename = "model", skip_serializing_if = "Option::is_none")]
    pub model: Option<String>,
}

impl UsageEmbeddingsResult {
    /// The aggregated embeddings usage details of the specific time bucket.
    pub fn new(
        object: Object,
        input_tokens: i32,
        num_model_requests: i32,
    ) -> UsageEmbeddingsResult {
        UsageEmbeddingsResult {
            object,
            input_tokens,
            num_model_requests,
            project_id: None,
            user_id: None,
            api_key_id: None,
            model: None,
        }
    }
}
///
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Object {
    #[serde(rename = "organization.usage.embeddings.result")]
    OrganizationUsageEmbeddingsResult,
}

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

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