1use super::input::present_optional;
4use super::response::{GenerateContentResponseBody, ResponseOutputItem};
5use crate::Rest;
6use serde::{Deserialize, Serialize};
7
8#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11#[serde(tag = "type")]
12#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
13#[derive(gproxy_protocol_macros::DeclaredFields)]
14pub enum StreamEvent {
15 #[serde(rename = "response.created")]
16 Created(ResponseCreated),
17 #[serde(rename = "response.queued")]
18 Queued(ResponseQueued),
19 #[serde(rename = "response.in_progress")]
20 InProgress(ResponseInProgress),
21 #[serde(rename = "response.completed")]
22 Completed(ResponseCompleted),
23 #[serde(rename = "response.failed")]
24 Failed(ResponseFailed),
25 #[serde(rename = "response.incomplete")]
26 Incomplete(ResponseIncomplete),
27 #[serde(rename = "response.output_item.added")]
28 OutputItemAdded(OutputItemEvent),
29 #[serde(rename = "response.output_item.done")]
30 OutputItemDone(OutputItemEvent),
31 #[serde(rename = "response.content_part.added")]
32 ContentPartAdded(ContentPartEvent),
33 #[serde(rename = "response.content_part.done")]
34 ContentPartDone(ContentPartEvent),
35 #[serde(rename = "response.output_text.delta")]
36 OutputTextDelta(OutputTextDelta),
37 #[serde(rename = "response.output_text.done")]
38 OutputTextDone(OutputTextDone),
39 #[serde(rename = "response.output_text.annotation.added")]
40 OutputTextAnnotationAdded(OutputTextAnnotationAdded),
41 #[serde(rename = "response.refusal.delta")]
42 RefusalDelta(RefusalDelta),
43 #[serde(rename = "response.refusal.done")]
44 RefusalDone(RefusalDone),
45 #[serde(rename = "response.reasoning_text.delta")]
46 ReasoningTextDelta(ReasoningTextDelta),
47 #[serde(rename = "response.reasoning_text.done")]
48 ReasoningTextDone(ReasoningTextDone),
49 #[serde(rename = "response.reasoning_summary_part.added")]
50 ReasoningSummaryPartAdded(ReasoningSummaryPartAddedEvent),
51 #[serde(rename = "response.reasoning_summary_part.done")]
52 ReasoningSummaryPartDone(ReasoningSummaryPartDoneEvent),
53 #[serde(rename = "response.reasoning_summary_text.delta")]
54 ReasoningSummaryTextDelta(ReasoningSummaryTextDelta),
55 #[serde(rename = "response.reasoning_summary_text.done")]
56 ReasoningSummaryTextDone(ReasoningSummaryTextDone),
57 #[serde(rename = "response.function_call_arguments.delta")]
58 FunctionCallArgumentsDelta(FunctionCallArgumentsDelta),
59 #[serde(rename = "response.function_call_arguments.done")]
60 FunctionCallArgumentsDone(FunctionCallArgumentsDone),
61 #[serde(rename = "response.custom_tool_call_input.delta")]
62 CustomToolInputDelta(CustomToolInputDelta),
63 #[serde(rename = "response.custom_tool_call_input.done")]
64 CustomToolInputDone(CustomToolInputDone),
65 #[serde(rename = "response.code_interpreter_call_code.delta")]
66 CodeInterpreterCodeDelta(CodeInterpreterCodeDelta),
67 #[serde(rename = "response.code_interpreter_call_code.done")]
68 CodeInterpreterCodeDone(CodeInterpreterCodeDone),
69 #[serde(rename = "response.audio.delta")]
70 AudioDelta(AudioDelta),
71 #[serde(rename = "response.audio.done")]
72 AudioDone(AudioDone),
73 #[serde(rename = "response.audio.transcript.delta")]
74 AudioTranscriptDelta(AudioTranscriptDelta),
75 #[serde(rename = "response.audio.transcript.done")]
76 AudioTranscriptDone(AudioTranscriptDone),
77 #[serde(rename = "response.image_generation_call.partial_image")]
78 ImagePartial(ImagePartial),
79 #[serde(rename = "response.image_generation_call.in_progress")]
80 ImageCall(ImageCallEvent),
81 #[serde(rename = "response.image_generation_call.generating")]
82 ImageGenerating(ImageCallEvent),
83 #[serde(rename = "response.image_generation_call.completed")]
84 ImageCompleted(ImageCallEvent),
85 #[serde(rename = "response.code_interpreter_call.in_progress")]
86 CodeInterpreterInProgress(CodeInterpreterEvent),
87 #[serde(rename = "response.code_interpreter_call.interpreting")]
88 CodeInterpreterInterpreting(CodeInterpreterEvent),
89 #[serde(rename = "response.code_interpreter_call.completed")]
90 CodeInterpreterCompleted(CodeInterpreterEvent),
91 #[serde(rename = "response.file_search_call.in_progress")]
92 FileSearchInProgress(ToolCallEvent),
93 #[serde(rename = "response.file_search_call.searching")]
94 FileSearchSearching(ToolCallEvent),
95 #[serde(rename = "response.file_search_call.completed")]
96 FileSearchCompleted(ToolCallEvent),
97 #[serde(rename = "response.web_search_call.in_progress")]
98 WebSearchInProgress(ToolCallEvent),
99 #[serde(rename = "response.web_search_call.searching")]
100 WebSearchSearching(ToolCallEvent),
101 #[serde(rename = "response.web_search_call.completed")]
102 WebSearchCompleted(ToolCallEvent),
103 #[serde(rename = "response.mcp_call_arguments.delta")]
104 McpArgumentsDelta(McpArgumentsDelta),
105 #[serde(rename = "response.mcp_call_arguments.done")]
106 McpArgumentsDone(McpArgumentsDone),
107 #[serde(rename = "response.mcp_call.in_progress")]
108 McpInProgress(McpCallEvent),
109 #[serde(rename = "response.mcp_call.completed")]
110 McpCompleted(McpCallEvent),
111 #[serde(rename = "response.mcp_call.failed")]
112 McpFailed(McpCallEvent),
113 #[serde(rename = "response.mcp_list_tools.in_progress")]
114 McpListToolsInProgress(McpListToolsEvent),
115 #[serde(rename = "response.mcp_list_tools.completed")]
116 McpListToolsCompleted(McpListToolsEvent),
117 #[serde(rename = "response.mcp_list_tools.failed")]
118 McpListToolsFailed(McpListToolsEvent),
119 #[serde(rename = "error")]
120 Error(ResponseErrorEvent),
121}
122macro_rules! event_struct { ($name:ident { $($field:ident : $ty:ty),* $(,)? }) => { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)] #[serde(rename_all="snake_case")] #[cfg_attr(not(feature="exhaustive"), non_exhaustive)] #[derive(gproxy_protocol_macros::DeclaredFields)]
123pub struct $name { pub sequence_number: i64, $(pub $field: $ty,)* #[serde(default, flatten, skip_serializing_if="serde_json::Map::is_empty")] pub rest: Rest } }; }
124macro_rules! agent_event_struct { ($name:ident { $($field:ident : $ty:ty),* $(,)? }) => { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)] #[serde(rename_all="snake_case")] #[cfg_attr(not(feature="exhaustive"), non_exhaustive)] #[derive(gproxy_protocol_macros::DeclaredFields)]
125pub struct $name { #[serde(default, deserialize_with = "super::input::present_nullable", skip_serializing_if = "Option::is_none")] pub agent: Option<Option<super::multi_agent::Agent>>, pub sequence_number: i64, $(pub $field: $ty,)* #[serde(default, flatten, skip_serializing_if="serde_json::Map::is_empty")] pub rest: Rest } }; }
126event_struct!(ResponseCreated {
127 response: GenerateContentResponseBody
128});
129event_struct!(ResponseQueued {
130 response: GenerateContentResponseBody
131});
132event_struct!(ResponseInProgress {
133 response: GenerateContentResponseBody
134});
135event_struct!(ResponseCompleted {
136 response: GenerateContentResponseBody
137});
138event_struct!(ResponseFailed {
139 response: GenerateContentResponseBody
140});
141event_struct!(ResponseIncomplete {
142 response: GenerateContentResponseBody
143});
144agent_event_struct!(OutputItemEvent {
145 output_index: i64,
146 item: ResponseOutputItem
147});
148agent_event_struct!(ContentPartEvent {
149 item_id: String,
150 output_index: i64,
151 content_index: i64,
152 part: OutputContentPart
153});
154agent_event_struct!(OutputTextDelta { item_id: String, output_index: i64, content_index: i64, delta: String, logprobs: Vec<StreamLogprob> });
155agent_event_struct!(OutputTextDone { item_id: String, output_index: i64, content_index: i64, text: String, logprobs: Vec<StreamLogprob> });
156agent_event_struct!(OutputTextAnnotationAdded {
157 item_id: String,
158 output_index: i64,
159 content_index: i64,
160 annotation_index: i64,
161 annotation: serde_json::Value
162});
163agent_event_struct!(RefusalDelta {
164 item_id: String,
165 output_index: i64,
166 content_index: i64,
167 delta: String
168});
169agent_event_struct!(RefusalDone {
170 item_id: String,
171 output_index: i64,
172 content_index: i64,
173 refusal: String
174});
175agent_event_struct!(ReasoningTextDelta {
176 item_id: String,
177 output_index: i64,
178 content_index: i64,
179 delta: String
180});
181agent_event_struct!(ReasoningTextDone {
182 item_id: String,
183 output_index: i64,
184 content_index: i64,
185 text: String
186});
187agent_event_struct!(ReasoningSummaryPartAddedEvent {
188 item_id: String,
189 output_index: i64,
190 summary_index: i64,
191 part: ReasoningSummaryPart
192});
193#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
194#[serde(rename_all = "snake_case")]
195#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
196#[derive(gproxy_protocol_macros::DeclaredFields)]
197pub struct ReasoningSummaryPartDoneEvent {
198 #[serde(
199 default,
200 deserialize_with = "super::input::present_nullable",
201 skip_serializing_if = "Option::is_none"
202 )]
203 pub agent: Option<Option<super::multi_agent::Agent>>,
204 pub sequence_number: i64,
205 pub item_id: String,
206 pub output_index: i64,
207 pub summary_index: i64,
208 pub part: ReasoningSummaryPart,
209 #[serde(
210 default,
211 deserialize_with = "present_optional",
212 skip_serializing_if = "Option::is_none"
213 )]
214 pub status: Option<SummaryPartStatus>,
215 #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
216 pub rest: Rest,
217}
218#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
219#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
220#[derive(gproxy_protocol_macros::DeclaredFields)]
221pub enum SummaryPartStatus {
222 #[serde(rename = "incomplete")]
223 Incomplete,
224}
225agent_event_struct!(ReasoningSummaryTextDelta {
226 item_id: String,
227 output_index: i64,
228 summary_index: i64,
229 delta: String
230});
231agent_event_struct!(ReasoningSummaryTextDone {
232 item_id: String,
233 output_index: i64,
234 summary_index: i64,
235 text: String
236});
237agent_event_struct!(FunctionCallArgumentsDelta {
238 item_id: String,
239 output_index: i64,
240 delta: String
241});
242agent_event_struct!(FunctionCallArgumentsDone {
243 item_id: String,
244 output_index: i64,
245 name: String,
246 arguments: String
247});
248agent_event_struct!(CustomToolInputDelta {
249 item_id: String,
250 output_index: i64,
251 delta: String
252});
253agent_event_struct!(CustomToolInputDone {
254 item_id: String,
255 output_index: i64,
256 input: String
257});
258agent_event_struct!(CodeInterpreterCodeDelta {
259 item_id: String,
260 output_index: i64,
261 delta: String
262});
263agent_event_struct!(CodeInterpreterCodeDone {
264 item_id: String,
265 output_index: i64,
266 code: String
267});
268agent_event_struct!(AudioDelta { delta: String });
269agent_event_struct!(AudioDone {});
270agent_event_struct!(AudioTranscriptDelta { delta: String });
271agent_event_struct!(AudioTranscriptDone {});
272agent_event_struct!(ImagePartial {
273 item_id: String,
274 output_index: i64,
275 partial_image_index: i64,
276 partial_image_b64: String
277});
278agent_event_struct!(ImageCall {
279 item_id: String,
280 output_index: i64
281});
282pub type ImageCallEvent = ImageCall;
283agent_event_struct!(CodeInterpreterEvent {
284 item_id: String,
285 output_index: i64
286});
287agent_event_struct!(ToolCallEvent {
288 item_id: String,
289 output_index: i64
290});
291agent_event_struct!(McpArgumentsDelta {
292 item_id: String,
293 output_index: i64,
294 delta: String
295});
296agent_event_struct!(McpArgumentsDone {
297 item_id: String,
298 output_index: i64,
299 arguments: String
300});
301agent_event_struct!(McpCallEvent {
302 item_id: String,
303 output_index: i64
304});
305agent_event_struct!(McpListToolsEvent {
306 item_id: String,
307 output_index: i64
308});
309pub type ResponseStream = crate::WireResponse<crate::connection::ByteStream>;
310
311#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
312#[serde(untagged)]
313#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
314#[derive(gproxy_protocol_macros::DeclaredFields)]
315pub enum OutputContentPart {
316 Text(super::input::ResponseOutputText),
317 Refusal(super::input::ResponseOutputRefusal),
318 Reasoning(ReasoningText),
319}
320#[derive(
321 Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
322)]
323#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
324#[derive(gproxy_protocol_macros::DeclaredFields)]
325pub struct ReasoningText {
326 pub text: String,
327 #[serde(rename = "type")]
328 pub type_: ReasoningTextType,
329 #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
330 pub rest: Rest,
331}
332#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
333#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
334#[derive(gproxy_protocol_macros::DeclaredFields)]
335pub enum ReasoningTextType {
336 #[serde(rename = "reasoning_text")]
337 ReasoningText,
338}
339#[derive(
340 Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
341)]
342#[serde(rename_all = "snake_case")]
343#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
344#[derive(gproxy_protocol_macros::DeclaredFields)]
345pub struct StreamLogprob {
346 pub token: String,
347 pub logprob: serde_json::Number,
348 #[serde(
349 default,
350 deserialize_with = "present_optional",
351 skip_serializing_if = "Option::is_none"
352 )]
353 pub top_logprobs: Option<Vec<StreamTopLogprob>>,
354 #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
355 pub rest: Rest,
356}
357#[derive(
358 Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
359)]
360#[serde(rename_all = "snake_case")]
361#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
362#[derive(gproxy_protocol_macros::DeclaredFields)]
363pub struct StreamTopLogprob {
364 #[serde(
365 default,
366 deserialize_with = "present_optional",
367 skip_serializing_if = "Option::is_none"
368 )]
369 pub token: Option<String>,
370 #[serde(
371 default,
372 deserialize_with = "present_optional",
373 skip_serializing_if = "Option::is_none"
374 )]
375 pub logprob: Option<serde_json::Number>,
376 #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
377 pub rest: Rest,
378}
379#[derive(
380 Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
381)]
382#[serde(rename_all = "snake_case")]
383#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
384#[derive(gproxy_protocol_macros::DeclaredFields)]
385pub struct ReasoningSummaryPart {
386 pub text: String,
387 #[serde(rename = "type")]
388 pub type_: ReasoningSummaryPartType,
389 #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
390 pub rest: Rest,
391}
392#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
393#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
394#[derive(gproxy_protocol_macros::DeclaredFields)]
395pub enum ReasoningSummaryPartType {
396 #[serde(rename = "summary_text")]
397 SummaryText,
398}
399#[derive(
400 Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
401)]
402#[serde(rename_all = "snake_case")]
403#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
404#[derive(gproxy_protocol_macros::DeclaredFields)]
405pub struct ResponseErrorEvent {
406 #[wire(required)]
407 #[serde(deserialize_with = "super::input::required_nullable")]
408 pub code: Option<String>,
409 pub message: String,
410 #[wire(required)]
411 #[serde(deserialize_with = "super::input::required_nullable")]
412 pub param: Option<String>,
413 pub sequence_number: i64,
414 #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
415 pub rest: Rest,
416}
417
418impl StreamEvent {
419 pub fn agent(&self) -> Option<&super::multi_agent::Agent> {
420 match self {
421 Self::OutputItemAdded(v) => v.agent.as_ref().and_then(Option::as_ref),
422 Self::OutputItemDone(v) => v.agent.as_ref().and_then(Option::as_ref),
423 Self::ContentPartAdded(v) => v.agent.as_ref().and_then(Option::as_ref),
424 Self::ContentPartDone(v) => v.agent.as_ref().and_then(Option::as_ref),
425 Self::OutputTextDelta(v) => v.agent.as_ref().and_then(Option::as_ref),
426 Self::OutputTextDone(v) => v.agent.as_ref().and_then(Option::as_ref),
427 Self::OutputTextAnnotationAdded(v) => v.agent.as_ref().and_then(Option::as_ref),
428 Self::RefusalDelta(v) => v.agent.as_ref().and_then(Option::as_ref),
429 Self::RefusalDone(v) => v.agent.as_ref().and_then(Option::as_ref),
430 Self::ReasoningTextDelta(v) => v.agent.as_ref().and_then(Option::as_ref),
431 Self::ReasoningTextDone(v) => v.agent.as_ref().and_then(Option::as_ref),
432 Self::ReasoningSummaryPartAdded(v) => v.agent.as_ref().and_then(Option::as_ref),
433 Self::ReasoningSummaryPartDone(v) => v.agent.as_ref().and_then(Option::as_ref),
434 Self::ReasoningSummaryTextDelta(v) => v.agent.as_ref().and_then(Option::as_ref),
435 Self::ReasoningSummaryTextDone(v) => v.agent.as_ref().and_then(Option::as_ref),
436 Self::FunctionCallArgumentsDelta(v) => v.agent.as_ref().and_then(Option::as_ref),
437 Self::FunctionCallArgumentsDone(v) => v.agent.as_ref().and_then(Option::as_ref),
438 Self::CustomToolInputDelta(v) => v.agent.as_ref().and_then(Option::as_ref),
439 Self::CustomToolInputDone(v) => v.agent.as_ref().and_then(Option::as_ref),
440 Self::CodeInterpreterCodeDelta(v) => v.agent.as_ref().and_then(Option::as_ref),
441 Self::CodeInterpreterCodeDone(v) => v.agent.as_ref().and_then(Option::as_ref),
442 Self::AudioDelta(v) => v.agent.as_ref().and_then(Option::as_ref),
443 Self::AudioDone(v) => v.agent.as_ref().and_then(Option::as_ref),
444 Self::AudioTranscriptDelta(v) => v.agent.as_ref().and_then(Option::as_ref),
445 Self::AudioTranscriptDone(v) => v.agent.as_ref().and_then(Option::as_ref),
446 Self::ImagePartial(v) => v.agent.as_ref().and_then(Option::as_ref),
447 Self::ImageCall(v) => v.agent.as_ref().and_then(Option::as_ref),
448 Self::ImageGenerating(v) => v.agent.as_ref().and_then(Option::as_ref),
449 Self::ImageCompleted(v) => v.agent.as_ref().and_then(Option::as_ref),
450 Self::CodeInterpreterInProgress(v) => v.agent.as_ref().and_then(Option::as_ref),
451 Self::CodeInterpreterInterpreting(v) => v.agent.as_ref().and_then(Option::as_ref),
452 Self::CodeInterpreterCompleted(v) => v.agent.as_ref().and_then(Option::as_ref),
453 Self::FileSearchInProgress(v) => v.agent.as_ref().and_then(Option::as_ref),
454 Self::FileSearchSearching(v) => v.agent.as_ref().and_then(Option::as_ref),
455 Self::FileSearchCompleted(v) => v.agent.as_ref().and_then(Option::as_ref),
456 Self::WebSearchInProgress(v) => v.agent.as_ref().and_then(Option::as_ref),
457 Self::WebSearchSearching(v) => v.agent.as_ref().and_then(Option::as_ref),
458 Self::WebSearchCompleted(v) => v.agent.as_ref().and_then(Option::as_ref),
459 Self::McpArgumentsDelta(v) => v.agent.as_ref().and_then(Option::as_ref),
460 Self::McpArgumentsDone(v) => v.agent.as_ref().and_then(Option::as_ref),
461 Self::McpInProgress(v) => v.agent.as_ref().and_then(Option::as_ref),
462 Self::McpCompleted(v) => v.agent.as_ref().and_then(Option::as_ref),
463 Self::McpFailed(v) => v.agent.as_ref().and_then(Option::as_ref),
464 Self::McpListToolsInProgress(v) => v.agent.as_ref().and_then(Option::as_ref),
465 Self::McpListToolsCompleted(v) => v.agent.as_ref().and_then(Option::as_ref),
466 Self::McpListToolsFailed(v) => v.agent.as_ref().and_then(Option::as_ref),
467 _ => None,
468 }
469 }
470 pub(crate) fn set_agent(&mut self, agent: Option<super::multi_agent::Agent>) {
471 match self {
472 Self::OutputItemAdded(v) => v.agent = agent.map(Some),
473 Self::OutputItemDone(v) => v.agent = agent.map(Some),
474 Self::ContentPartAdded(v) => v.agent = agent.map(Some),
475 Self::ContentPartDone(v) => v.agent = agent.map(Some),
476 Self::OutputTextDelta(v) => v.agent = agent.map(Some),
477 Self::OutputTextDone(v) => v.agent = agent.map(Some),
478 Self::OutputTextAnnotationAdded(v) => v.agent = agent.map(Some),
479 Self::RefusalDelta(v) => v.agent = agent.map(Some),
480 Self::RefusalDone(v) => v.agent = agent.map(Some),
481 Self::ReasoningTextDelta(v) => v.agent = agent.map(Some),
482 Self::ReasoningTextDone(v) => v.agent = agent.map(Some),
483 Self::ReasoningSummaryPartAdded(v) => v.agent = agent.map(Some),
484 Self::ReasoningSummaryPartDone(v) => v.agent = agent.map(Some),
485 Self::ReasoningSummaryTextDelta(v) => v.agent = agent.map(Some),
486 Self::ReasoningSummaryTextDone(v) => v.agent = agent.map(Some),
487 Self::FunctionCallArgumentsDelta(v) => v.agent = agent.map(Some),
488 Self::FunctionCallArgumentsDone(v) => v.agent = agent.map(Some),
489 Self::CustomToolInputDelta(v) => v.agent = agent.map(Some),
490 Self::CustomToolInputDone(v) => v.agent = agent.map(Some),
491 Self::CodeInterpreterCodeDelta(v) => v.agent = agent.map(Some),
492 Self::CodeInterpreterCodeDone(v) => v.agent = agent.map(Some),
493 Self::AudioDelta(v) => v.agent = agent.map(Some),
494 Self::AudioDone(v) => v.agent = agent.map(Some),
495 Self::AudioTranscriptDelta(v) => v.agent = agent.map(Some),
496 Self::AudioTranscriptDone(v) => v.agent = agent.map(Some),
497 Self::ImagePartial(v) => v.agent = agent.map(Some),
498 Self::ImageCall(v) => v.agent = agent.map(Some),
499 Self::ImageGenerating(v) => v.agent = agent.map(Some),
500 Self::ImageCompleted(v) => v.agent = agent.map(Some),
501 Self::CodeInterpreterInProgress(v) => v.agent = agent.map(Some),
502 Self::CodeInterpreterInterpreting(v) => v.agent = agent.map(Some),
503 Self::CodeInterpreterCompleted(v) => v.agent = agent.map(Some),
504 Self::FileSearchInProgress(v) => v.agent = agent.map(Some),
505 Self::FileSearchSearching(v) => v.agent = agent.map(Some),
506 Self::FileSearchCompleted(v) => v.agent = agent.map(Some),
507 Self::WebSearchInProgress(v) => v.agent = agent.map(Some),
508 Self::WebSearchSearching(v) => v.agent = agent.map(Some),
509 Self::WebSearchCompleted(v) => v.agent = agent.map(Some),
510 Self::McpArgumentsDelta(v) => v.agent = agent.map(Some),
511 Self::McpArgumentsDone(v) => v.agent = agent.map(Some),
512 Self::McpInProgress(v) => v.agent = agent.map(Some),
513 Self::McpCompleted(v) => v.agent = agent.map(Some),
514 Self::McpFailed(v) => v.agent = agent.map(Some),
515 Self::McpListToolsInProgress(v) => v.agent = agent.map(Some),
516 Self::McpListToolsCompleted(v) => v.agent = agent.map(Some),
517 Self::McpListToolsFailed(v) => v.agent = agent.map(Some),
518 _ => {}
519 }
520 }
521}
522
523impl StreamEvent {
524 pub(crate) fn output_index(&self) -> Option<i64> {
525 match self {
526 Self::OutputItemAdded(v) => Some(v.output_index),
527 Self::OutputItemDone(v) => Some(v.output_index),
528 Self::ContentPartAdded(v) => Some(v.output_index),
529 Self::ContentPartDone(v) => Some(v.output_index),
530 Self::OutputTextDelta(v) => Some(v.output_index),
531 Self::OutputTextDone(v) => Some(v.output_index),
532 Self::OutputTextAnnotationAdded(v) => Some(v.output_index),
533 Self::RefusalDelta(v) => Some(v.output_index),
534 Self::RefusalDone(v) => Some(v.output_index),
535 Self::ReasoningTextDelta(v) => Some(v.output_index),
536 Self::ReasoningTextDone(v) => Some(v.output_index),
537 Self::ReasoningSummaryPartAdded(v) => Some(v.output_index),
538 Self::ReasoningSummaryPartDone(v) => Some(v.output_index),
539 Self::ReasoningSummaryTextDelta(v) => Some(v.output_index),
540 Self::ReasoningSummaryTextDone(v) => Some(v.output_index),
541 Self::FunctionCallArgumentsDelta(v) => Some(v.output_index),
542 Self::FunctionCallArgumentsDone(v) => Some(v.output_index),
543 Self::CustomToolInputDelta(v) => Some(v.output_index),
544 Self::CustomToolInputDone(v) => Some(v.output_index),
545 Self::CodeInterpreterCodeDelta(v) => Some(v.output_index),
546 Self::CodeInterpreterCodeDone(v) => Some(v.output_index),
547 Self::ImagePartial(v) => Some(v.output_index),
548 Self::ImageCall(v) | Self::ImageGenerating(v) | Self::ImageCompleted(v) => {
549 Some(v.output_index)
550 }
551 Self::CodeInterpreterInProgress(v) => Some(v.output_index),
552 Self::CodeInterpreterInterpreting(v) => Some(v.output_index),
553 Self::CodeInterpreterCompleted(v) => Some(v.output_index),
554 Self::FileSearchInProgress(v) => Some(v.output_index),
555 Self::FileSearchSearching(v) => Some(v.output_index),
556 Self::FileSearchCompleted(v) => Some(v.output_index),
557 Self::WebSearchInProgress(v) => Some(v.output_index),
558 Self::WebSearchSearching(v) => Some(v.output_index),
559 Self::WebSearchCompleted(v) => Some(v.output_index),
560 Self::McpArgumentsDelta(v) => Some(v.output_index),
561 Self::McpArgumentsDone(v) => Some(v.output_index),
562 Self::McpInProgress(v) => Some(v.output_index),
563 Self::McpCompleted(v) => Some(v.output_index),
564 Self::McpFailed(v) => Some(v.output_index),
565 Self::McpListToolsInProgress(v) => Some(v.output_index),
566 Self::McpListToolsCompleted(v) => Some(v.output_index),
567 Self::McpListToolsFailed(v) => Some(v.output_index),
568 _ => None,
569 }
570 }
571}