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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
//! Assistant-related types and structures for the Assistants API.
/// Define a private namespace for assistant-related items.
mod private
{
// Use full paths from crate root for components
use crate::components::common::
{
Metadata,
TextResponseFormatConfiguration,
ResponseFormatJsonObject,
ResponseFormatJsonSchema,
};
use crate::components::tools::{ Tool, ToolChoiceFunction, FileSearchRankingOptions };
// Add serde imports
use serde::{ Serialize, Deserialize };
/// Represents the supported models for Assistants. Placeholder type.
#[ derive( Debug, Serialize, Deserialize, Clone, PartialEq ) ]
pub struct AssistantSupportedModels
{
/// The model identifier string.
pub value : String,
}
/// Specifies the format that the model must output. Compatible with GPT-4o, GPT-4 Turbo, and newer GPT-3.5 Turbo models.
/// Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs.
/// Setting to `{ "type": "json_object" }` enables JSON mode.
/// `auto` is the default value.
///
/// # Used By
/// - `AssistantObject`
/// - `CreateAssistantRequest`
/// - `ModifyAssistantRequest`
/// - `RunObject`
/// - `CreateRunRequest`
/// - `CreateThreadAndRunRequest`
#[ derive( Debug, Serialize, Deserialize, Clone, PartialEq ) ]
#[ serde( untagged ) ] // Allows deserialization from string "auto" or the object types
pub enum AssistantsApiResponseFormatOption
{
/// Default value, lets the model decide. String value must be "auto".
Auto( String ),
/// Text format configuration.
Text( TextResponseFormatConfiguration ),
/// JSON object format configuration.
JsonObject( ResponseFormatJsonObject ),
/// JSON schema format configuration.
JsonSchema( ResponseFormatJsonSchema ),
}
/// Controls which (if any) tool is called by the model in the Assistants API.
/// `none` means the model will not call any tools.
/// `auto` is the default value and means the model can pick.
/// `required` means the model must call one or more tools.
/// Specifying a particular tool forces the model to call that tool.
///
/// # Used By
/// - `CreateRunRequest`
/// - `CreateThreadAndRunRequest`
/// - `RunObject`
#[ derive( Debug, Serialize, Deserialize, Clone, PartialEq ) ]
#[ serde( untagged ) ] // Allows deserialization from string or object
pub enum AssistantsApiToolChoiceOption
{
/// String options : "none", "auto", "required".
String( String ),
/// Specifies a specific tool to call.
Named( AssistantsNamedToolChoice ),
}
/// Specifies a tool the model should use within the Assistants API. Use to force the model to call a specific tool.
///
/// # Used By
/// - `AssistantsApiToolChoiceOption::Named`
#[ derive( Debug, Serialize, Deserialize, Clone, PartialEq ) ]
pub struct AssistantsNamedToolChoice
{
/// The type of the tool (`function`, `code_interpreter`, `file_search`).
pub r#type : String,
/// The function details if type is `function`.
pub function : Option< ToolChoiceFunction >,
}
/// Controls for how a thread will be truncated prior to the run.
///
/// # Used By
/// - `RunObject`
/// - `CreateRunRequest`
/// - `CreateThreadAndRunRequest`
#[ derive( Debug, Serialize, Deserialize, Clone, PartialEq ) ] // Added Serialize
pub struct TruncationObject
{
/// The truncation strategy type (`auto` or `last_messages`).
pub r#type : String,
/// The number of most recent messages to keep when `type` is `last_messages`.
pub last_messages : Option< i32 >,
}
/// Represents the Code Interpreter tool for Assistants.
///
/// # Used By
/// - `AssistantObject.tools`
/// - `CreateAssistantRequest.tools`
/// - `ModifyAssistantRequest.tools`
/// - `CreateRunRequest.tools`
/// - `CreateThreadAndRunRequest.tools`
/// - `MessageAttachment.tools`
#[ derive( Debug, Serialize, Deserialize, Clone, PartialEq ) ]
pub struct AssistantToolsCode
{
// Type is implicitly "code_interpreter" via parent enum tag
}
/// Represents the File Search tool for Assistants, with optional overrides.
///
/// # Used By
/// - `AssistantObject.tools`
/// - `CreateAssistantRequest.tools`
/// - `ModifyAssistantRequest.tools`
/// - `CreateRunRequest.tools`
/// - `CreateThreadAndRunRequest.tools`
#[ derive( Debug, Serialize, Deserialize, Clone, PartialEq ) ]
pub struct AssistantToolsFileSearch
{
/// Optional settings to override the default file search behavior.
#[ serde( skip_serializing_if = "Option::is_none" ) ]
pub file_search : Option< AssistantFileSearchSettings >,
}
/// Settings to override the File Search tool behavior.
///
/// # Used By
/// - `AssistantToolsFileSearch`
#[ derive( Debug, Serialize, Deserialize, Clone, PartialEq ) ]
pub struct AssistantFileSearchSettings
{
/// The maximum number of results the file search tool should output.
#[ serde( skip_serializing_if = "Option::is_none" ) ]
pub max_num_results : Option< i32 >,
/// Ranking options for the file search results.
#[ serde( skip_serializing_if = "Option::is_none" ) ]
pub ranking_options : Option< FileSearchRankingOptions >,
}
/// Represents the File Search tool type marker, used when attaching files to messages.
///
/// # Used By
/// - `MessageAttachment.tools`
#[ derive( Debug, Serialize, Deserialize, Clone, PartialEq ) ]
pub struct AssistantToolsFileSearchTypeOnly
{
// Type is implicitly "file_search" via parent enum tag
}
/// Represents the Function tool for Assistants.
///
/// # Used By
/// - `AssistantObject.tools`
/// - `CreateAssistantRequest.tools`
/// - `ModifyAssistantRequest.tools`
/// - `CreateRunRequest.tools`
/// - `CreateThreadAndRunRequest.tools`
#[ derive( Debug, Serialize, Deserialize, Clone, PartialEq ) ]
pub struct AssistantToolsFunction
{
/// The function definition.
pub function : crate::components::tools::FunctionTool,
}
/// Represents an `assistant` that can call the model and use tools.
///
/// # Used By
/// - `/assistants` (GET - in `ListAssistantsResponse`, POST response)
/// - `/assistants/{assistant_id}` (GET, POST response)
/// - `MessageObject`
/// - `RunObject`
/// - `RunStepObject`
#[ derive( Debug, Serialize, Deserialize, Clone, PartialEq ) ] // Added Serialize
pub struct AssistantObject
{
/// The identifier, which can be referenced in API endpoints.
pub id : String,
/// The object type, which is always `assistant`.
pub object : String,
/// The Unix timestamp (in seconds) for when the assistant was created.
pub created_at : i64,
/// The name of the assistant. The maximum length is 256 characters.
pub name : Option< String >,
/// The description of the assistant. The maximum length is 512 characters.
pub description : Option< String >,
/// ID of the model to use.
pub model : String,
/// The system instructions that the assistant uses. The maximum length is 256,000 characters.
pub instructions : Option< String >,
/// A list of tool enabled on the assistant. Maximum 128 tools.
pub tools : Vec< Tool >,
/// A set of resources used by the assistant's tools.
pub tool_resources : Option< ToolResources >,
/// Set of 16 key-value pairs attached to the object.
pub metadata : Option< Metadata >,
/// Sampling temperature between 0 and 2. Defaults to 1.
pub temperature : Option< f32 >,
/// Nucleus sampling probability. Defaults to 1.
pub top_p : Option< f32 >,
/// The response format specified for the assistant.
pub response_format : Option< AssistantsApiResponseFormatOption >,
}
/// A set of resources that are used by the assistant's tools.
///
/// # Used By
/// - `AssistantObject`
/// - `ThreadObject`
/// - `CreateAssistantRequest`
/// - `ModifyAssistantRequest`
/// - `CreateThreadRequest`
/// - `ModifyThreadRequest`
/// - `CreateThreadAndRunRequest`
#[ derive( Debug, Serialize, Deserialize, Clone, PartialEq ) ]
pub struct ToolResources
{
/// Resources for the Code Interpreter tool.
#[ serde( skip_serializing_if = "Option::is_none" ) ]
pub code_interpreter : Option< CodeInterpreterResources >,
/// Resources for the File Search tool.
#[ serde( skip_serializing_if = "Option::is_none" ) ]
pub file_search : Option< FileSearchResources >,
}
/// Resources for the Code Interpreter tool.
///
/// # Used By
/// - `ToolResources`
#[ derive( Debug, Serialize, Deserialize, Clone, PartialEq ) ]
pub struct CodeInterpreterResources
{
/// A list of file IDs made available to the Code Interpreter tool. Maximum 20 files.
#[ serde( default, skip_serializing_if = "Option::is_none" ) ] // Default to empty vec if None during serialization
pub file_ids : Option< Vec< String > >,
}
/// Resources for the File Search tool.
///
/// # Used By
/// - `ToolResources`
#[ derive( Debug, Serialize, Deserialize, Clone, PartialEq ) ]
pub struct FileSearchResources
{
/// The vector store IDs attached to the assistant or thread. Maximum 1 ID.
#[ serde( skip_serializing_if = "Option::is_none" ) ]
pub vector_store_ids : Option< Vec< String > >,
// Note : 'vector_stores' field from CreateAssistantRequest/CreateThreadRequest is not part of the response object.
}
/// Response containing a list of assistants.
///
/// # Used By
/// - `/assistants` (GET)
#[ derive( Debug, Deserialize, Clone, PartialEq ) ]
pub struct ListAssistantsResponse
{
/// The object type, always "list".
pub object : String,
/// A list of assistant objects.
pub data : Vec< AssistantObject >,
/// The ID of the first assistant in the list.
pub first_id : String,
/// The ID of the last assistant in the list.
pub last_id : String,
/// Indicates whether there are more assistants available.
pub has_more : bool,
}
/// Response structure for deletion operations of assistants.
///
/// # Used By
/// - `/assistants/{assistant_id}` (DELETE)
#[ derive( Debug, Deserialize, Clone, PartialEq ) ]
pub struct DeleteAssistantResponse
{
/// The ID of the deleted assistant.
pub id : String,
/// The object type, always "assistant.deleted".
pub object : String,
/// Whether the deletion was successful.
pub deleted : bool,
}
}
crate ::mod_interface!
{
exposed use private::AssistantSupportedModels;
exposed use private::AssistantsApiResponseFormatOption;
exposed use private::AssistantsApiToolChoiceOption;
exposed use private::AssistantsNamedToolChoice;
exposed use private::TruncationObject;
exposed use private::AssistantToolsCode;
exposed use private::AssistantToolsFileSearch;
exposed use private::AssistantFileSearchSettings;
exposed use private::AssistantToolsFileSearchTypeOnly;
exposed use private::AssistantToolsFunction;
exposed use private::AssistantObject;
exposed use private::ToolResources;
exposed use private::CodeInterpreterResources;
exposed use private::FileSearchResources;
exposed use private::ListAssistantsResponse;
exposed use private::DeleteAssistantResponse;
}