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

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct BetaCompactResponseMethodPublicBody {
    /// ID of the model to use
    #[serde(rename = "model")]
    pub model: String,
    #[serde(
        rename = "input",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub input: Option<Option<Box<models::BetaTokenCountsBodyInput>>>,
    /// The unique ID of the previous response to the model. Use this to create multi-turn conversations. Learn more about [conversation state](https://developers.openai.com/api/docs/guides/conversation-state). Cannot be used in conjunction with `conversation`.
    #[serde(
        rename = "previous_response_id",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub previous_response_id: Option<Option<String>>,
    /// A system (or developer) message inserted into the model's context. When used along with `previous_response_id`, the instructions from a previous response will not be carried over to the next response. This makes it simple to swap out system (or developer) messages in new responses.
    #[serde(
        rename = "instructions",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub instructions: Option<Option<String>>,
    /// A key to use when reading from or writing to the prompt cache.
    #[serde(
        rename = "prompt_cache_key",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub prompt_cache_key: Option<Option<String>>,
    #[serde(
        rename = "prompt_cache_retention",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub prompt_cache_retention: Option<Option<models::BetaPromptCacheRetentionEnum>>,
    #[serde(
        rename = "prompt_cache_options",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub prompt_cache_options: Option<Option<Box<models::BetaPromptCacheOptionsParam>>>,
    #[serde(
        rename = "service_tier",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub service_tier: Option<Option<models::BetaServiceTierEnum>>,
}

impl BetaCompactResponseMethodPublicBody {
    pub fn new(model: String) -> BetaCompactResponseMethodPublicBody {
        BetaCompactResponseMethodPublicBody {
            model,
            input: None,
            previous_response_id: None,
            instructions: None,
            prompt_cache_key: None,
            prompt_cache_retention: None,
            prompt_cache_options: None,
            service_tier: None,
        }
    }
}

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