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, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct TokenCountsBody {
    /// ID of the model to use
    #[serde(rename = "model", skip_serializing_if = "Option::is_none")]
    pub model: Option<String>,
    #[serde(
        rename = "input",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub input: Option<Option<Box<models::TokenCountsBodyInput>>>,
    /// The unique ID of the previous response to the model. Use this to create multi-turn conversations. Learn more about [conversation state](/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>>,
    /// An array of tools the model may call while generating a response. You can specify which tool to use by setting the `tool_choice` parameter.
    #[serde(
        rename = "tools",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub tools: Option<Option<Vec<models::Tool>>>,
    #[serde(
        rename = "text",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub text: Option<Option<Box<models::ResponseTextParam>>>,
    #[serde(
        rename = "reasoning",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub reasoning: Option<Option<Box<models::Reasoning>>>,
    #[serde(rename = "truncation", skip_serializing_if = "Option::is_none")]
    pub truncation: Option<models::TruncationEnum>,
    /// 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>>,
    #[serde(
        rename = "conversation",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub conversation: Option<Option<Box<models::ConversationParam>>>,
    #[serde(
        rename = "tool_choice",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub tool_choice: Option<Option<Box<models::ToolChoiceParam>>>,
    /// Whether to allow the model to run tool calls in parallel.
    #[serde(
        rename = "parallel_tool_calls",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub parallel_tool_calls: Option<Option<bool>>,
}

impl TokenCountsBody {
    pub fn new() -> TokenCountsBody {
        TokenCountsBody {
            model: None,
            input: None,
            previous_response_id: None,
            tools: None,
            text: None,
            reasoning: None,
            truncation: None,
            instructions: None,
            conversation: None,
            tool_choice: None,
            parallel_tool_calls: None,
        }
    }
}

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