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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
use serde::{Deserialize, Serialize};
use super::{Annotation, OutputContent, OutputItem, Response};
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(tag = "type")]
pub enum Event {
/// An event that is emitted when a response is created.
#[serde(rename = "response.created")]
ResponseCreated {
/// The response that was created.
response: Response,
},
/// Emitted when the response is in progress.
#[serde(rename = "response.in_progress")]
ResponseInProgress {
/// The response that is in progress.
response: Response,
},
/// Emitted when the model response is complete.
#[serde(rename = "response.completed")]
ResponseCompleted {
/// Properties of the completed response.
response: Response,
},
/// An event that is emitted when a response fails.
#[serde(rename = "response.failed")]
ResponseFailed {
/// The response that failed.
response: Response,
}, // todo: probably we just care about error?
/// An event that is emitted when a response finishes as incomplete.
#[serde(rename = "response.incomplete")]
ResponseIncomplete {
/// The response that was incomplete.
response: Response,
},
/// Emitted when a new output item is added.
#[serde(rename = "response.output_item.added")]
OutputItemAdded {
/// The output item that was added.
item: OutputItem,
/// The index of the output item that was added.
output_index: u64,
},
/// Emitted when an output item is marked done.
#[serde(rename = "response.output_item.done")]
OutputItemDone {
/// The output item that was marked done.
item: OutputItem,
/// The index of the output item that was marked done.
output_index: u64,
},
/// Emitted when a new content part is added.
#[serde(rename = "response.content_part.added")]
ContentPartAdded {
/// The index of the content part that was added.
content_index: u64,
/// The ID of the output item that the content part was added to.
item_id: String,
/// The index of the output item that the content part was added to.
output_index: u64,
/// The content part that was added.
part: OutputContent,
},
/// Emitted when a content part is done.
#[serde(rename = "response.content_part.done")]
ContentPartDone {
/// The index of the content part that is done.
content_index: u64,
/// The ID of the output item that the content part was added to.
item_id: String,
/// The index of the output item that the content part was added to.
output_index: u64,
/// The content part that is done.
part: OutputContent,
},
/// Emitted when there is an additional text delta.
#[serde(rename = "response.output_text.delta")]
OutputTextDelta {
/// The index of the content part that the text delta was added to.
content_index: u64,
/// The text delta that was added.
delta: String,
/// The ID of the output item that the text delta was added to.
item_id: String,
/// The index of the output item that the text delta was added to.
output_index: u64,
},
/// Emitted when a text annotation is added.
#[serde(rename = "response.output_text.annotation.added")]
OutputTextAnnotationAdded {
/// The annotation that was added.
annotation: Annotation,
/// The index of the annotation that was added.
annotation_index: u64,
/// The index of the content part that the text annotation was added to.
content_index: u64,
/// The ID of the output item that the text annotation was added to.
item_id: String,
/// The index of the output item that the text annotation was added to.
output_index: u64,
},
/// Emitted when text content is finalized.
#[serde(rename = "response.output_text.done")]
OutputTextDone {
/// The index of the content part that the text content is finalized.
content_index: u64,
/// The ID of the output item that the text content is finalized.
item_id: String,
/// The index of the output item that the text content is finalized.
output_index: u64,
/// The text content that is finalized.
text: String,
},
/// Emitted when there is a partial refusal text.
#[serde(rename = "response.refusal.delta")]
RefusalDelta {
/// The index of the content part that the refusal text is added to.
content_index: u64,
/// The refusal text that is added.
delta: String,
/// The ID of the output item that the refusal text is added to.
item_id: String,
/// The index of the output item that the refusal text is added to.
output_index: u64,
},
/// Emitted when refusal text is finalized.
#[serde(rename = "response.refusal.done")]
RefusalDone {
/// The index of the content part that the refusal text is finalized.
content_index: u64,
/// The ID of the output item that the refusal text is finalized.
item_id: String,
/// The index of the output item that the refusal text is finalized.
output_index: u64,
/// The refusal text that is finalized.
refusal: String,
},
/// Emitted when there is a partial function-call arguments delta.
#[serde(rename = "response.function_call_arguments.delta")]
FunctionCallArgumentsDelta {
/// The function-call arguments delta that is added.
delta: String,
/// The ID of the output item that the function-call arguments delta is added to.
item_id: String,
/// The index of the output item that the function-call arguments delta is added to.
output_index: u64,
},
/// Emitted when function-call arguments are finalized.
#[serde(rename = "response.function_call_arguments.done")]
FunctionCallArgumentsDone {
/// The function-call arguments.
arguments: String,
/// The ID of the item.
item_id: String,
/// The index of the output item.
output_index: u64,
},
/// Emitted when a file search call is initiated.
#[serde(rename = "response.file_search_call.in_progress")]
FileSearchCallInitiated {
/// The ID of the output item that the file search call is initiated.
item_id: String,
/// The index of the output item that the file search call is initiated.
output_index: u64,
},
/// Emitted when a file search is currently searching.
#[serde(rename = "response.file_search_call.searching")]
FileSearchCallSearching {
/// The ID of the output item that the file search call is searching.
item_id: String,
/// The index of the output item that the file search call is searching.
output_index: u64,
},
/// Emitted when a file search call is completed (results found).
#[serde(rename = "response.file_search_call.completed")]
FileSearchCallCompleted {
/// The ID of the output item that the file search call completed at.
item_id: String,
/// The index of the output item that the file search call completed at.
output_index: u64,
},
/// Emitted when a web search call is initiated.
#[serde(rename = "response.web_search_call.in_progress")]
WebSearchCallInitiated {
/// Unique ID for the output item associated with the web search call.
item_id: String,
/// The index of the output item that the web search call is associated with.
output_index: u64,
},
/// Emitted when a web search call is executing.
#[serde(rename = "response.web_search_call.searching")]
WebSearchCallSearching {
/// Unique ID for the output item associated with the web search call.
item_id: String,
/// The index of the output item that the web search call is associated with.
output_index: u64,
},
/// Emitted when a web search call is completed.
#[serde(rename = "response.web_search_call.completed")]
WebSearchCallCompleted {
/// Unique ID for the output item associated with the web search call.
item_id: String,
/// The index of the output item that the web search call is associated with.
output_index: u64,
},
/// Emitted when an error occurs.
#[serde(rename = "error")]
Error {
/// The error code.
code: Option<String>,
/// The error message.
message: String,
/// The error parameter.
param: Option<String>,
},
}