use serde::Serialize;
use validator::Validate;
use super::super::traits::*;
#[derive(Debug, Clone, Serialize, Validate)]
pub struct AudioToTextBody<N>
where
N: ModelName + AudioToText + Serialize,
{
pub model: N,
#[serde(skip_serializing_if = "Option::is_none")]
#[validate(range(min = 0.0, max = 1.0))]
pub temperature: Option<f32>,
#[serde(skip_serializing_if = "Option::is_none")]
pub stream: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub request_id: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
#[validate(length(min = 6, max = 128))]
pub user_id: Option<String>,
}
impl<N> AudioToTextBody<N>
where
N: ModelName + AudioToText + Serialize,
{
pub fn new(model: N) -> Self {
Self {
model,
temperature: None,
stream: None,
request_id: None,
user_id: None,
}
}
pub fn with_temperature(mut self, temperature: f32) -> Self {
self.temperature = Some(temperature);
self
}
pub fn with_stream(mut self, stream: bool) -> Self {
self.stream = Some(stream);
self
}
pub fn with_request_id(mut self, request_id: impl Into<String>) -> Self {
self.request_id = Some(request_id.into());
self
}
pub fn with_user_id(mut self, user_id: impl Into<String>) -> Self {
self.user_id = Some(user_id.into());
self
}
}