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

/// SemanticVad : Server-side semantic turn detection which uses a model to determine when the user has finished speaking.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct SemanticVad {
    /// Type of turn detection, `semantic_vad` to turn on Semantic VAD.
    #[serde(rename = "type")]
    pub r#type: Type,
    /// Used only for `semantic_vad` mode. The eagerness of the model to respond. `low` will wait longer for the user to continue speaking, `high` will respond more quickly. `auto` is the default and is equivalent to `medium`. `low`, `medium`, and `high` have max timeouts of 8s, 4s, and 2s respectively.
    #[serde(rename = "eagerness", skip_serializing_if = "Option::is_none")]
    pub eagerness: Option<Eagerness>,
    /// Whether or not to automatically generate a response when a VAD stop event occurs.
    #[serde(rename = "create_response", skip_serializing_if = "Option::is_none")]
    pub create_response: Option<bool>,
    /// Whether or not to automatically interrupt any ongoing response with output to the default conversation (i.e. `conversation` of `auto`) when a VAD start event occurs.
    #[serde(rename = "interrupt_response", skip_serializing_if = "Option::is_none")]
    pub interrupt_response: Option<bool>,
}

impl SemanticVad {
    /// Server-side semantic turn detection which uses a model to determine when the user has finished speaking.
    pub fn new(r#type: Type) -> SemanticVad {
        SemanticVad {
            r#type,
            eagerness: None,
            create_response: None,
            interrupt_response: None,
        }
    }
}
/// Type of turn detection, `semantic_vad` to turn on Semantic VAD.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
    #[serde(rename = "semantic_vad")]
    SemanticVad,
}

impl Default for Type {
    fn default() -> Type {
        Self::SemanticVad
    }
}
/// Used only for `semantic_vad` mode. The eagerness of the model to respond. `low` will wait longer for the user to continue speaking, `high` will respond more quickly. `auto` is the default and is equivalent to `medium`. `low`, `medium`, and `high` have max timeouts of 8s, 4s, and 2s respectively.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Eagerness {
    #[serde(rename = "low")]
    Low,
    #[serde(rename = "medium")]
    Medium,
    #[serde(rename = "high")]
    High,
    #[serde(rename = "auto")]
    Auto,
}

impl Default for Eagerness {
    fn default() -> Eagerness {
        Self::Low
    }
}

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