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

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct TranscriptionSegment {
    /// Unique identifier of the segment.
    #[serde(rename = "id")]
    pub id: i32,
    /// Seek offset of the segment.
    #[serde(rename = "seek")]
    pub seek: i32,
    /// Start time of the segment in seconds.
    #[serde(rename = "start")]
    pub start: f32,
    /// End time of the segment in seconds.
    #[serde(rename = "end")]
    pub end: f32,
    /// Text content of the segment.
    #[serde(rename = "text")]
    pub text: String,
    /// Array of token IDs for the text content.
    #[serde(rename = "tokens")]
    pub tokens: Vec<i32>,
    /// Temperature parameter used for generating the segment.
    #[serde(rename = "temperature")]
    pub temperature: f32,
    /// Average logprob of the segment. If the value is lower than -1, consider the logprobs failed.
    #[serde(rename = "avg_logprob")]
    pub avg_logprob: f32,
    /// Compression ratio of the segment. If the value is greater than 2.4, consider the compression failed.
    #[serde(rename = "compression_ratio")]
    pub compression_ratio: f32,
    /// Probability of no speech in the segment. If the value is higher than 1.0 and the `avg_logprob` is below -1, consider this segment silent.
    #[serde(rename = "no_speech_prob")]
    pub no_speech_prob: f32,
}

impl TranscriptionSegment {
    pub fn new(
        id: i32,
        seek: i32,
        start: f32,
        end: f32,
        text: String,
        tokens: Vec<i32>,
        temperature: f32,
        avg_logprob: f32,
        compression_ratio: f32,
        no_speech_prob: f32,
    ) -> TranscriptionSegment {
        TranscriptionSegment {
            id,
            seek,
            start,
            end,
            text,
            tokens,
            temperature,
            avg_logprob,
            compression_ratio,
            no_speech_prob,
        }
    }
}

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