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

/// CreateTranscriptionResponseDiarizedJson : Represents a diarized transcription response returned by the model, including the combined transcript and speaker-segment annotations.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct CreateTranscriptionResponseDiarizedJson {
    /// The type of task that was run. Always `transcribe`.
    #[serde(rename = "task")]
    pub task: Task,
    /// Duration of the input audio in seconds.
    #[serde(rename = "duration")]
    pub duration: f64,
    /// The concatenated transcript text for the entire audio input.
    #[serde(rename = "text")]
    pub text: String,
    /// Segments of the transcript annotated with timestamps and speaker labels.
    #[serde(rename = "segments")]
    pub segments: Vec<models::TranscriptionDiarizedSegment>,
    #[serde(rename = "usage", skip_serializing_if = "Option::is_none")]
    pub usage: Option<Box<models::CreateTranscriptionResponseDiarizedJsonUsage>>,
}

impl CreateTranscriptionResponseDiarizedJson {
    /// Represents a diarized transcription response returned by the model, including the combined transcript and speaker-segment annotations.
    pub fn new(
        task: Task,
        duration: f64,
        text: String,
        segments: Vec<models::TranscriptionDiarizedSegment>,
    ) -> CreateTranscriptionResponseDiarizedJson {
        CreateTranscriptionResponseDiarizedJson {
            task,
            duration,
            text,
            segments,
            usage: None,
        }
    }
}
/// The type of task that was run. Always `transcribe`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Task {
    #[serde(rename = "transcribe")]
    Transcribe,
}

impl Default for Task {
    fn default() -> Task {
        Self::Transcribe
    }
}

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