Skip to main content

gproxy_protocol/openai/generate_content/responses/stream/payloads/
content.rs

1use serde::{Deserialize, Serialize};
2use serde_json::Value;
3
4use crate::openai::common::{Rest, StreamTokenLogprob};
5
6use super::super::super::ResponseContentPart;
7
8#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
9#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
10pub struct ResponseContentPartEvent {
11    pub content_index: u32,
12    pub item_id: String,
13    pub output_index: u32,
14    pub part: ResponseContentPart,
15    #[serde(skip_serializing_if = "Option::is_none")]
16    pub sequence_number: Option<u64>,
17    #[serde(default, flatten)]
18    pub rest: Rest,
19}
20
21#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
22#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
23pub struct ResponseOutputTextDeltaEvent {
24    // The Codex backend can omit the content index on sparse interrupted frames.
25    #[serde(skip_serializing_if = "Option::is_none")]
26    pub content_index: Option<u32>,
27    pub delta: String,
28    pub item_id: String,
29    #[serde(skip_serializing_if = "Option::is_none")]
30    pub logprobs: Option<Vec<StreamTokenLogprob>>,
31    pub output_index: u32,
32    #[serde(skip_serializing_if = "Option::is_none")]
33    pub sequence_number: Option<u64>,
34    #[serde(default, flatten)]
35    pub rest: Rest,
36}
37
38#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
39#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
40pub struct ResponseOutputTextDoneEvent {
41    pub content_index: u32,
42    pub item_id: String,
43    #[serde(skip_serializing_if = "Option::is_none")]
44    pub logprobs: Option<Vec<StreamTokenLogprob>>,
45    pub output_index: u32,
46    #[serde(skip_serializing_if = "Option::is_none")]
47    pub sequence_number: Option<u64>,
48    pub text: String,
49    #[serde(default, flatten)]
50    pub rest: Rest,
51}
52
53#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
54#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
55pub struct ResponseOutputTextAnnotationEvent {
56    // OpenAI deliberately documents the streamed annotation payload as unknown.
57    pub annotation: Value,
58    pub annotation_index: u32,
59    pub content_index: u32,
60    pub item_id: String,
61    pub output_index: u32,
62    #[serde(skip_serializing_if = "Option::is_none")]
63    pub sequence_number: Option<u64>,
64    #[serde(default, flatten)]
65    pub rest: Rest,
66}
67
68#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
69#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
70pub struct ResponseContentDeltaEvent {
71    pub content_index: u32,
72    pub delta: String,
73    pub item_id: String,
74    pub output_index: u32,
75    #[serde(skip_serializing_if = "Option::is_none")]
76    pub sequence_number: Option<u64>,
77    #[serde(default, flatten)]
78    pub rest: Rest,
79}
80
81#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
82#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
83pub struct ResponseRefusalDoneEvent {
84    pub content_index: u32,
85    pub item_id: String,
86    pub output_index: u32,
87    pub refusal: String,
88    #[serde(skip_serializing_if = "Option::is_none")]
89    pub sequence_number: Option<u64>,
90    #[serde(default, flatten)]
91    pub rest: Rest,
92}
93
94#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
95#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
96pub struct ResponseContentTextDoneEvent {
97    pub content_index: u32,
98    pub item_id: String,
99    pub output_index: u32,
100    #[serde(skip_serializing_if = "Option::is_none")]
101    pub sequence_number: Option<u64>,
102    pub text: String,
103    #[serde(default, flatten)]
104    pub rest: Rest,
105}
106
107#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
108#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
109pub struct ResponseAudioDeltaEvent {
110    pub delta: String,
111    #[serde(skip_serializing_if = "Option::is_none")]
112    pub sequence_number: Option<u64>,
113    #[serde(default, flatten)]
114    pub rest: Rest,
115}