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

/// TranscriptTextDeltaEvent : Emitted when there is an additional text delta. This is also the first event emitted when the transcription starts. Only emitted when you [create a transcription](/docs/api-reference/audio/create-transcription) with the `Stream` parameter set to `true`.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct TranscriptTextDeltaEvent {
    /// The type of the event. Always `transcript.text.delta`.
    #[serde(rename = "type")]
    pub r#type: Type,
    /// The text delta that was additionally transcribed.
    #[serde(rename = "delta")]
    pub delta: String,
    /// The log probabilities of the delta. Only included if you [create a transcription](/docs/api-reference/audio/create-transcription) with the `include[]` parameter set to `logprobs`.
    #[serde(rename = "logprobs", skip_serializing_if = "Option::is_none")]
    pub logprobs: Option<Vec<models::TranscriptTextDeltaEventLogprobsInner>>,
    /// Identifier of the diarized segment that this delta belongs to. Only present when using `gpt-4o-transcribe-diarize`.
    #[serde(rename = "segment_id", skip_serializing_if = "Option::is_none")]
    pub segment_id: Option<String>,
}

impl TranscriptTextDeltaEvent {
    /// Emitted when there is an additional text delta. This is also the first event emitted when the transcription starts. Only emitted when you [create a transcription](/docs/api-reference/audio/create-transcription) with the `Stream` parameter set to `true`.
    pub fn new(r#type: Type, delta: String) -> TranscriptTextDeltaEvent {
        TranscriptTextDeltaEvent {
            r#type,
            delta,
            logprobs: None,
            segment_id: None,
        }
    }
}
/// The type of the event. Always `transcript.text.delta`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
    #[serde(rename = "transcript.text.delta")]
    TranscriptTextDelta,
}

impl Default for Type {
    fn default() -> Type {
        Self::TranscriptTextDelta
    }
}

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