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
/*
* 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};
/// LiveResponseEvent : A streaming Responses API event from a backend delegated to by the Live session. Use the outer delegation_id to associate the nested stream with its Live delegation.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct LiveResponseEvent {
/// The unique ID of the Live server event.
#[serde(rename = "event_id")]
pub event_id: String,
/// The event_id of the client command associated with this server event, when supplied.
#[serde(rename = "client_event_id", skip_serializing_if = "Option::is_none")]
pub client_event_id: Option<String>,
/// The event type, always `response.event`.
#[serde(rename = "type")]
pub r#type: Type,
/// The Live delegation associated with the nested Responses event. May be null or omitted when the event cannot be correlated with a delegation.
#[serde(
rename = "delegation_id",
default,
with = "::serde_with::rust::double_option",
skip_serializing_if = "Option::is_none"
)]
pub delegation_id: Option<Option<String>>,
/// The nested Responses streaming event. Dispatch on its type field. Response lifecycle snapshots omit input and clear instructions, tools, and output to keep messages small; consume granular output events for the generated content.
#[serde(rename = "event")]
pub event: std::collections::HashMap<String, serde_json::Value>,
}
impl LiveResponseEvent {
/// A streaming Responses API event from a backend delegated to by the Live session. Use the outer delegation_id to associate the nested stream with its Live delegation.
pub fn new(
event_id: String,
r#type: Type,
event: std::collections::HashMap<String, serde_json::Value>,
) -> LiveResponseEvent {
LiveResponseEvent {
event_id,
client_event_id: None,
r#type,
delegation_id: None,
event,
}
}
}
/// The event type, always `response.event`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
#[serde(rename = "response.event")]
ResponseEvent,
}
impl Default for Type {
fn default() -> Type {
Self::ResponseEvent
}
}
impl std::fmt::Display for LiveResponseEvent {
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),
}
}
}