zai_rs/model/audio_to_text/
request.rs1use serde::Serialize;
2use validator::Validate;
3
4use super::super::traits::*;
5
6#[derive(Debug, Clone, Serialize, Validate)]
9pub struct AudioToTextBody<N>
10where
11 N: ModelName + AudioToText + Serialize,
12{
13 pub model: N,
15
16 #[serde(skip_serializing_if = "Option::is_none")]
18 #[validate(range(min = 0.0, max = 1.0))]
19 pub temperature: Option<f32>,
20
21 #[serde(skip_serializing_if = "Option::is_none")]
23 pub stream: Option<bool>,
24
25 #[serde(skip_serializing_if = "Option::is_none")]
27 pub request_id: Option<String>,
28
29 #[serde(skip_serializing_if = "Option::is_none")]
31 #[validate(length(min = 6, max = 128))]
32 pub user_id: Option<String>,
33}
34
35impl<N> AudioToTextBody<N>
36where
37 N: ModelName + AudioToText + Serialize,
38{
39 pub fn new(model: N) -> Self {
40 Self {
41 model,
42 temperature: None,
43 stream: None,
44 request_id: None,
45 user_id: None,
46 }
47 }
48
49 pub fn with_temperature(mut self, temperature: f32) -> Self {
50 self.temperature = Some(temperature);
51 self
52 }
53
54 pub fn with_stream(mut self, stream: bool) -> Self {
55 self.stream = Some(stream);
56 self
57 }
58
59 pub fn with_request_id(mut self, request_id: impl Into<String>) -> Self {
60 self.request_id = Some(request_id.into());
61 self
62 }
63
64 pub fn with_user_id(mut self, user_id: impl Into<String>) -> Self {
65 self.user_id = Some(user_id.into());
66 self
67 }
68}