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

/// CreateTranscriptionResponseVerboseJson : Represents a verbose json transcription response returned by model, based on the provided input.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct CreateTranscriptionResponseVerboseJson {
    /// The language of the input audio.
    #[serde(rename = "language")]
    pub language: String,
    /// The duration of the input audio.
    #[serde(rename = "duration")]
    pub duration: f64,
    /// The transcribed text.
    #[serde(rename = "text")]
    pub text: String,
    /// Extracted words and their corresponding timestamps.
    #[serde(rename = "words", skip_serializing_if = "Option::is_none")]
    pub words: Option<Vec<models::TranscriptionWord>>,
    /// Segments of the transcribed text and their corresponding details.
    #[serde(rename = "segments", skip_serializing_if = "Option::is_none")]
    pub segments: Option<Vec<models::TranscriptionSegment>>,
    #[serde(rename = "usage", skip_serializing_if = "Option::is_none")]
    pub usage: Option<Box<models::TranscriptTextUsageDuration>>,
}

impl CreateTranscriptionResponseVerboseJson {
    /// Represents a verbose json transcription response returned by model, based on the provided input.
    pub fn new(
        language: String,
        duration: f64,
        text: String,
    ) -> CreateTranscriptionResponseVerboseJson {
        CreateTranscriptionResponseVerboseJson {
            language,
            duration,
            text,
            words: None,
            segments: None,
            usage: None,
        }
    }
}

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