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

/// TranscriptTextDoneEvent : Emitted when the transcription is complete. Contains the complete transcription text. 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 TranscriptTextDoneEvent {
    /// The type of the event. Always `transcript.text.done`.
    #[serde(rename = "type")]
    pub r#type: Type,
    /// The text that was transcribed.
    #[serde(rename = "text")]
    pub text: String,
    /// The log probabilities of the individual tokens in the transcription. 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>>,
    #[serde(rename = "usage", skip_serializing_if = "Option::is_none")]
    pub usage: Option<Box<models::TranscriptTextUsageTokens>>,
}

impl TranscriptTextDoneEvent {
    /// Emitted when the transcription is complete. Contains the complete transcription text. 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, text: String) -> TranscriptTextDoneEvent {
        TranscriptTextDoneEvent {
            r#type,
            text,
            logprobs: None,
            usage: None,
        }
    }
}
/// The type of the event. Always `transcript.text.done`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
    #[serde(rename = "transcript.text.done")]
    TranscriptTextDone,
}

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

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