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

/// RealtimeSessionCreateRequestGa : Realtime session object configuration.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct RealtimeSessionCreateRequestGa {
    /// The type of session to create. Always `realtime` for the Realtime API.
    #[serde(rename = "type")]
    pub r#type: Type,
    /// The set of modalities the model can respond with. It defaults to `[\"audio\"]`, indicating that the model will respond with audio plus a transcript. `[\"text\"]` can be used to make the model respond with text only. It is not possible to request both `text` and `audio` at the same time.
    #[serde(rename = "output_modalities", skip_serializing_if = "Option::is_none")]
    pub output_modalities: Option<Vec<OutputModalities>>,
    /// The Realtime model used for this session.
    #[serde(rename = "model", skip_serializing_if = "Option::is_none")]
    pub model: Option<String>,
    /// The default system instructions (i.e. system message) prepended to model calls. This field allows the client to guide the model on desired responses. The model can be instructed on response content and format, (e.g. \"be extremely succinct\", \"act friendly\", \"here are examples of good responses\") and on audio behavior (e.g. \"talk quickly\", \"inject emotion into your voice\", \"laugh frequently\"). The instructions are not guaranteed to be followed by the model, but they provide guidance to the model on the desired behavior.  Note that the server sets default instructions which will be used if this field is not set and are visible in the `session.created` event at the start of the session.
    #[serde(rename = "instructions", skip_serializing_if = "Option::is_none")]
    pub instructions: Option<String>,
    #[serde(rename = "audio", skip_serializing_if = "Option::is_none")]
    pub audio: Option<Box<models::RealtimeSessionCreateRequestGaAudio>>,
    /// Additional fields to include in server outputs.  `item.input_audio_transcription.logprobs`: Include logprobs for input audio transcription.
    #[serde(rename = "include", skip_serializing_if = "Option::is_none")]
    pub include: Option<Vec<Include>>,
    #[serde(rename = "tracing", skip_serializing_if = "Option::is_none")]
    pub tracing: Option<Box<models::RealtimeSessionCreateRequestGaTracing>>,
    /// Tools available to the model.
    #[serde(rename = "tools", skip_serializing_if = "Option::is_none")]
    pub tools: Option<Vec<models::RealtimeResponseCreateParamsToolsInner>>,
    #[serde(rename = "tool_choice", skip_serializing_if = "Option::is_none")]
    pub tool_choice: Option<Box<models::RealtimeBetaResponseCreateParamsToolChoice>>,
    #[serde(rename = "max_output_tokens", skip_serializing_if = "Option::is_none")]
    pub max_output_tokens: Option<Box<models::RealtimeBetaResponseCreateParamsMaxOutputTokens>>,
    #[serde(rename = "truncation", skip_serializing_if = "Option::is_none")]
    pub truncation: Option<Box<models::RealtimeTruncation>>,
    #[serde(
        rename = "prompt",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub prompt: Option<Option<Box<models::Prompt>>>,
}

impl RealtimeSessionCreateRequestGa {
    /// Realtime session object configuration.
    pub fn new(r#type: Type) -> RealtimeSessionCreateRequestGa {
        RealtimeSessionCreateRequestGa {
            r#type,
            output_modalities: None,
            model: None,
            instructions: None,
            audio: None,
            include: None,
            tracing: None,
            tools: None,
            tool_choice: None,
            max_output_tokens: None,
            truncation: None,
            prompt: None,
        }
    }
}
/// The type of session to create. Always `realtime` for the Realtime API.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
    #[serde(rename = "realtime")]
    Realtime,
}

impl Default for Type {
    fn default() -> Type {
        Self::Realtime
    }
}
/// The set of modalities the model can respond with. It defaults to `[\"audio\"]`, indicating that the model will respond with audio plus a transcript. `[\"text\"]` can be used to make the model respond with text only. It is not possible to request both `text` and `audio` at the same time.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum OutputModalities {
    #[serde(rename = "text")]
    Text,
    #[serde(rename = "audio")]
    Audio,
}

impl Default for OutputModalities {
    fn default() -> OutputModalities {
        Self::Text
    }
}
/// Additional fields to include in server outputs.  `item.input_audio_transcription.logprobs`: Include logprobs for input audio transcription.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Include {
    #[serde(rename = "item.input_audio_transcription.logprobs")]
    ItemInputAudioTranscriptionLogprobs,
}

impl Default for Include {
    fn default() -> Include {
        Self::ItemInputAudioTranscriptionLogprobs
    }
}

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