/*
* 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};
/// RealtimeSessionCreateRequest : A new Realtime session configuration, with an ephemeral key. Default TTL for keys is one minute.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct RealtimeSessionCreateRequest {
#[serde(rename = "client_secret")]
pub client_secret: Box<models::RealtimeSessionCreateRequestClientSecret>,
#[serde(
rename = "modalities",
default,
with = "::serde_with::rust::double_option",
skip_serializing_if = "Option::is_none"
)]
pub modalities: Option<Option<serde_json::Value>>,
/// 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 = "voice", skip_serializing_if = "Option::is_none")]
pub voice: Option<Box<models::VoiceIdsOrCustomVoice>>,
/// The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`.
#[serde(rename = "input_audio_format", skip_serializing_if = "Option::is_none")]
pub input_audio_format: Option<String>,
/// The format of output audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`.
#[serde(
rename = "output_audio_format",
skip_serializing_if = "Option::is_none"
)]
pub output_audio_format: Option<String>,
#[serde(
rename = "input_audio_transcription",
skip_serializing_if = "Option::is_none"
)]
pub input_audio_transcription:
Option<Box<models::RealtimeSessionCreateRequestInputAudioTranscription>>,
/// The speed of the model's spoken response. 1.0 is the default speed. 0.25 is the minimum speed. 1.5 is the maximum speed. This value can only be changed in between model turns, not while a response is in progress.
#[serde(rename = "speed", skip_serializing_if = "Option::is_none")]
pub speed: Option<f64>,
#[serde(rename = "tracing", skip_serializing_if = "Option::is_none")]
pub tracing: Option<Box<models::RealtimeSessionCreateRequestTracing>>,
#[serde(rename = "turn_detection", skip_serializing_if = "Option::is_none")]
pub turn_detection: Option<Box<models::RealtimeSessionCreateRequestTurnDetection>>,
/// Tools (functions) available to the model.
#[serde(rename = "tools", skip_serializing_if = "Option::is_none")]
pub tools: Option<Vec<models::RealtimeSessionCreateRequestToolsInner>>,
/// How the model chooses tools. Options are `auto`, `none`, `required`, or specify a function.
#[serde(rename = "tool_choice", skip_serializing_if = "Option::is_none")]
pub tool_choice: Option<String>,
/// Sampling temperature for the model, limited to [0.6, 1.2]. Defaults to 0.8.
#[serde(rename = "temperature", skip_serializing_if = "Option::is_none")]
pub temperature: Option<f64>,
#[serde(
rename = "max_response_output_tokens",
skip_serializing_if = "Option::is_none"
)]
pub max_response_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 RealtimeSessionCreateRequest {
/// A new Realtime session configuration, with an ephemeral key. Default TTL for keys is one minute.
pub fn new(
client_secret: models::RealtimeSessionCreateRequestClientSecret,
) -> RealtimeSessionCreateRequest {
RealtimeSessionCreateRequest {
client_secret: Box::new(client_secret),
modalities: None,
instructions: None,
voice: None,
input_audio_format: None,
output_audio_format: None,
input_audio_transcription: None,
speed: None,
tracing: None,
turn_detection: None,
tools: None,
tool_choice: None,
temperature: None,
max_response_output_tokens: None,
truncation: None,
prompt: None,
}
}
}
impl std::fmt::Display for RealtimeSessionCreateRequest {
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),
}
}
}