1use serde::{Deserialize, Serialize};
5
6use super::common::{ImageDetail, Role};
7use super::output::{FunctionToolCall, ReasoningItem};
8
9#[derive(Debug, Clone, Serialize)]
11#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
12#[serde(untagged)]
13#[non_exhaustive]
14pub enum ResponseInput {
15 Text(String),
17 Messages(Vec<ResponseInputItem>),
19 Items(Vec<serde_json::Value>),
21}
22
23impl From<&str> for ResponseInput {
24 fn from(s: &str) -> Self {
25 ResponseInput::Text(s.to_string())
26 }
27}
28
29impl From<String> for ResponseInput {
30 fn from(s: String) -> Self {
31 ResponseInput::Text(s)
32 }
33}
34
35#[derive(Debug, Clone, Serialize, Deserialize)]
37#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
38pub struct ResponseInputItem {
39 pub role: Role,
41 pub content: serde_json::Value,
43}
44
45#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
50#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
51pub struct EasyInputMessage {
52 #[serde(rename = "type")]
54 pub r#type: MessageType,
55 pub role: Role,
57 pub content: EasyInputContent,
59}
60
61#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
63#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
64#[non_exhaustive]
65pub enum MessageType {
66 #[serde(rename = "message")]
68 Message,
69}
70
71#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
73#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
74#[serde(untagged)]
75#[non_exhaustive]
76pub enum EasyInputContent {
77 Text(String),
79 ContentList(Vec<InputContent>),
81}
82
83#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
87#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
88#[serde(tag = "type")]
89#[non_exhaustive]
90pub enum InputContent {
91 #[serde(rename = "input_text")]
93 InputText(InputTextContent),
94 #[serde(rename = "input_image")]
96 InputImage(InputImageContent),
97}
98
99#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
101#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
102pub struct InputTextContent {
103 pub text: String,
105}
106
107#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
111#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
112pub struct InputImageContent {
113 pub detail: ImageDetail,
115 #[serde(default)]
117 #[serde(skip_serializing_if = "Option::is_none")]
118 pub file_id: Option<String>,
119 #[serde(default)]
121 #[serde(skip_serializing_if = "Option::is_none")]
122 pub image_url: Option<String>,
123}
124
125#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
129#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
130#[serde(untagged)]
131#[non_exhaustive]
132pub enum InputItem {
133 EasyMessage(EasyInputMessage),
135 Item(Item),
137}
138
139#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
143#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
144#[serde(tag = "type")]
145#[non_exhaustive]
146pub enum Item {
147 #[serde(rename = "function_call")]
149 FunctionCall(FunctionToolCall),
150 #[serde(rename = "function_call_output")]
152 FunctionCallOutput(FunctionCallOutputItemParam),
153 #[serde(rename = "reasoning")]
155 Reasoning(ReasoningItem),
156}
157
158#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
162#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
163pub struct FunctionCallOutputItemParam {
164 pub call_id: String,
166 pub output: FunctionCallOutput,
168 #[serde(default)]
170 #[serde(skip_serializing_if = "Option::is_none")]
171 pub id: Option<String>,
172 #[serde(default)]
174 #[serde(skip_serializing_if = "Option::is_none")]
175 pub status: Option<String>,
176}
177
178#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
180#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
181#[serde(untagged)]
182#[non_exhaustive]
183pub enum FunctionCallOutput {
184 Text(String),
186}
187
188#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
192#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
193#[non_exhaustive]
194pub enum IncludeEnum {
195 #[serde(rename = "file_search_call.results")]
197 FileSearchCallResults,
198 #[serde(rename = "web_search_call.results")]
200 WebSearchCallResults,
201 #[serde(rename = "reasoning.encrypted_content")]
203 ReasoningEncryptedContent,
204 #[serde(rename = "message.input_image.image_url")]
206 MessageInputImageUrl,
207 #[serde(rename = "computer_call_output.output.image_url")]
209 ComputerCallOutputImageUrl,
210 #[serde(rename = "code_interpreter_call.outputs")]
212 CodeInterpreterCallOutputs,
213 #[serde(rename = "message.output_text.logprobs")]
215 MessageOutputTextLogprobs,
216}
217
218#[derive(Debug, Clone, Serialize, Deserialize)]
222#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
223#[serde(untagged)]
224#[non_exhaustive]
225pub enum InputParam {
226 Text(String),
228 Items(Vec<InputItem>),
230}