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
//! Structures related to input content parts and messages.
/// Define a private namespace for all its items.
mod private
{
use serde::{ Deserialize, Serialize };
use former::Former;
/// Represents a text input part within a message's content.
///
/// # Used By
/// - `InputContentPart`
/// - `ChatCompletionRequestMessageContentPartText` (within `chat_shared.rs`)
/// - `ChatCompletionRequestSystemMessageContentPart` (within `chat_shared.rs`)
/// - `ChatCompletionRequestToolMessageContentPart` (within `chat_shared.rs`)
/// - `ChatCompletionRequestUserMessageContentPart` (within `chat_shared.rs`)
/// - `MessageRequestContentTextObject` (within `assistants_shared.rs`)
#[ derive( Debug, Serialize, Deserialize, Clone, PartialEq, Former ) ]
pub struct InputText
{
/// The text content.
pub text : String,
}
impl Default for InputText
{
/// Creates a default `InputText` with an empty string.
#[ inline ]
fn default() -> Self
{
Self { text : String::new() }
}
}
/// Represents an image input part, specified either by URL or File ID.
/// Learn about [image inputs](/docs/guides/vision).
///
/// # Used By
/// - `InputContentPart`
/// - `ChatCompletionRequestMessageContentPartImage` (within `chat_shared.rs`)
#[ derive( Debug, Serialize, Deserialize, Clone, PartialEq, Former, Default ) ]
pub struct InputImage
{
/// The URL of the image or a base64 encoded data URL.
#[ serde( skip_serializing_if = "Option::is_none" ) ]
pub image_url : Option< String >,
/// The ID of an uploaded file to use as input.
#[ serde( skip_serializing_if = "Option::is_none" ) ]
pub file_id : Option< String >,
/// Specifies the detail level of the image (`low`, `high`, or `auto`). Defaults to `auto`.
#[ serde( skip_serializing_if = "Option::is_none" ) ]
pub detail : Option< String >,
}
/// Represents a file input part, specified by File ID or embedded data.
/// Learn about [file inputs](/docs/guides/text) for text generation.
///
/// # Used By
/// - `InputContentPart`
/// - `ChatCompletionRequestMessageContentPartFile` (within `chat_shared.rs`)
#[ derive( Debug, Serialize, Deserialize, Clone, PartialEq, Former, Default ) ]
pub struct InputFile
{
/// The ID of an uploaded file to use as input.
#[ serde( skip_serializing_if = "Option::is_none" ) ]
pub file_id : Option< String >,
/// The name of the file, used when passing the file to the model as a string.
#[ serde( skip_serializing_if = "Option::is_none" ) ]
pub filename : Option< String >,
/// The base64 encoded file data, used when passing the file to the model as a string.
#[ serde( skip_serializing_if = "Option::is_none" ) ]
pub file_data : Option< String >,
}
/// Represents different types of input content parts within a message for request creation.
///
/// # Used By
/// - `InputMessage`
#[ derive( Debug, Serialize, Deserialize, Clone, PartialEq ) ]
#[ serde( tag = "type" ) ]
pub enum InputContentPart
{
/// Text content.
#[ serde( rename = "input_text" ) ]
Text( InputText ),
/// Image content (URL or file ID).
#[ serde( rename = "input_image" ) ]
Image( InputImage ),
/// File content (file ID or data).
#[ serde( rename = "input_file" ) ]
File( InputFile ),
}
/// Represents a message input item for request creation, including role and content.
///
/// # Used By
/// - `InputItem`
#[ derive( Debug, Serialize, Deserialize, Clone, PartialEq, Former ) ]
pub struct InputMessage
{
/// The type of the item, always "message".
#[ former( default = "message".to_string() ) ]
pub r#type : String,
/// The role of the message author (e.g., "user", "system", "developer").
pub role : String,
/// The content parts of the message (text, image, file).
pub content : Vec< InputContentPart >,
/// The status of the item (`in_progress`, `completed`, `incomplete`). Populated when returned via API.
#[ serde( skip_serializing_if = "Option::is_none" ) ]
pub status : Option< String >,
/// The unique ID of the message input. Populated when returned via API.
#[ serde( skip_serializing_if = "Option::is_none" ) ]
pub id : Option< String >,
}
impl Default for InputMessage
{
/// Creates a default `InputMessage` with type "message" and role "user".
#[ inline ]
fn default() -> Self
{
Self
{
r#type : "message".to_string(),
role : "user".to_string(),
content : Vec::new(),
status : None,
id : None,
}
}
}
/// Represents an input item within a request, currently only supporting messages.
///
/// # Used By
/// - `ResponseInput` (within `responses.rs`)
#[ derive( Debug, Serialize, Deserialize, Clone, PartialEq ) ]
#[ serde( untagged ) ]
pub enum InputItem
{
/// An input message.
Message( InputMessage ),
// Potentially other item types like ItemReference could be added here.
}
/// Represents a content part within a listed input item (used in file search results).
///
/// # Used By
/// - `ListedInputItem`
/// - `FileSearchResultItem` (within `output.rs`)
#[ derive( Debug, Serialize, Deserialize, Clone, PartialEq, Default ) ] // Added Serialize
pub struct ListedInputContentPart
{
/// The type of the content part (e.g., "`input_text`").
pub r#type : String,
/// The text content.
pub text : String,
}
/// Represents an input item as returned by the list operation (e.g., listing response inputs).
///
/// # Used By
/// - `ResponseItemList` (within `responses.rs`)
#[ derive( Debug, Deserialize, Clone, PartialEq ) ]
pub struct ListedInputItem
{
/// The unique ID of the input item (message).
pub id : String,
/// The role of the message author (e.g., "user").
pub role : String,
/// The content parts of the message.
#[ serde( default ) ]
pub content : Vec< ListedInputContentPart >,
/// Optional name for the participant.
#[ serde( skip_serializing_if = "Option::is_none" ) ]
pub name : Option< String >,
/// The status of the item (`completed`, etc.).
#[ serde( skip_serializing_if = "Option::is_none" ) ]
pub status : Option< String >,
/// The type of the item (e.g., "message").
#[ serde( skip_serializing_if = "Option::is_none" ) ]
pub r#type : Option< String >,
}
} // end mod private
crate ::mod_interface!
{
exposed use
{
InputText,
InputImage,
InputFile,
InputContentPart,
InputMessage,
InputItem,
ListedInputContentPart,
ListedInputItem,
};
}