1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*
* 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};
/// RealtimeResponseStatusDetails : Additional details about the status.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct RealtimeResponseStatusDetails {
/// The type of error that caused the response to fail, corresponding with the `status` field (`completed`, `cancelled`, `incomplete`, `failed`).
#[serde(rename = "type", skip_serializing_if = "Option::is_none")]
pub r#type: Option<Type>,
/// The reason the Response did not complete. For a `cancelled` Response, one of `turn_detected` (the server VAD detected a new start of speech) or `client_cancelled` (the client sent a cancel event). For an `incomplete` Response, one of `max_output_tokens` or `content_filter` (the server-side safety filter activated and cut off the response).
#[serde(rename = "reason", skip_serializing_if = "Option::is_none")]
pub reason: Option<Reason>,
#[serde(rename = "error", skip_serializing_if = "Option::is_none")]
pub error: Option<Box<models::RealtimeBetaResponseStatusDetailsError>>,
}
impl RealtimeResponseStatusDetails {
/// Additional details about the status.
pub fn new() -> RealtimeResponseStatusDetails {
RealtimeResponseStatusDetails {
r#type: None,
reason: None,
error: None,
}
}
}
/// The type of error that caused the response to fail, corresponding with the `status` field (`completed`, `cancelled`, `incomplete`, `failed`).
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
#[serde(rename = "completed")]
Completed,
#[serde(rename = "cancelled")]
Cancelled,
#[serde(rename = "failed")]
Failed,
#[serde(rename = "incomplete")]
Incomplete,
}
impl Default for Type {
fn default() -> Type {
Self::Completed
}
}
/// The reason the Response did not complete. For a `cancelled` Response, one of `turn_detected` (the server VAD detected a new start of speech) or `client_cancelled` (the client sent a cancel event). For an `incomplete` Response, one of `max_output_tokens` or `content_filter` (the server-side safety filter activated and cut off the response).
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Reason {
#[serde(rename = "turn_detected")]
TurnDetected,
#[serde(rename = "client_cancelled")]
ClientCancelled,
#[serde(rename = "max_output_tokens")]
MaxOutputTokens,
#[serde(rename = "content_filter")]
ContentFilter,
}
impl Default for Reason {
fn default() -> Reason {
Self::TurnDetected
}
}
impl std::fmt::Display for RealtimeResponseStatusDetails {
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),
}
}
}