Skip to main content

openai_types/beta/
_gen.rs

1// AUTO-GENERATED by py2rust — do not edit.
2// Re-generate: python3 scripts/py2rust.py sync <python_dir> <rust_dir>
3// Domain: beta
4#![allow(unused_imports)]
5
6use serde::{Deserialize, Serialize};
7use super::*;
8
9#[derive(Debug, Clone, Serialize, Deserialize)]
10#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
11pub struct ToolResourcesCodeInterpreter {
12    /// A list of [file](https://platform.openai.com/docs/api-reference/files) IDs made
13    #[serde(skip_serializing_if = "Option::is_none", default)]
14    pub file_ids: Option<Vec<String>>,
15}
16
17#[derive(Debug, Clone, Serialize, Deserialize)]
18#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
19pub struct ToolResourcesFileSearch {
20    /// The ID of the
21    #[serde(skip_serializing_if = "Option::is_none", default)]
22    pub vector_store_ids: Option<Vec<String>>,
23}
24
25/// A set of resources that are used by the assistant's tools.
26#[derive(Debug, Clone, Serialize, Deserialize)]
27#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
28pub struct ToolResources {
29    #[serde(skip_serializing_if = "Option::is_none", default)]
30    pub code_interpreter: Option<ToolResourcesCodeInterpreter>,
31    #[serde(skip_serializing_if = "Option::is_none", default)]
32    pub file_search: Option<ToolResourcesFileSearch>,
33}
34
35#[derive(Debug, Clone, Serialize, Deserialize)]
36#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
37pub struct AssistantCreateParams {
38    /// ID of the model to use.
39    pub model: String,
40    /// The description of the assistant. The maximum length is 512 characters.
41    #[serde(skip_serializing_if = "Option::is_none", default)]
42    pub description: Option<String>,
43    /// The system instructions that the assistant uses.
44    #[serde(skip_serializing_if = "Option::is_none", default)]
45    pub instructions: Option<String>,
46    /// Set of 16 key-value pairs that can be attached to an object.
47    #[serde(skip_serializing_if = "Option::is_none", default)]
48    pub metadata: Option<serde_json::Value>,
49    /// The name of the assistant. The maximum length is 256 characters.
50    #[serde(skip_serializing_if = "Option::is_none", default)]
51    pub name: Option<String>,
52    /// Constrains effort on reasoning for
53    #[serde(skip_serializing_if = "Option::is_none", default)]
54    pub reasoning_effort: Option<serde_json::Value>,
55    /// Specifies the format that the model must output.
56    #[serde(skip_serializing_if = "Option::is_none", default)]
57    pub response_format: Option<serde_json::Value>,
58    /// What sampling temperature to use, between 0 and 2.
59    #[serde(skip_serializing_if = "Option::is_none", default)]
60    pub temperature: Option<f64>,
61    /// A set of resources that are used by the assistant's tools.
62    #[serde(skip_serializing_if = "Option::is_none", default)]
63    pub tool_resources: Option<ToolResources>,
64    /// A list of tool enabled on the assistant.
65    #[serde(skip_serializing_if = "Option::is_none", default)]
66    pub tools: Option<Vec<serde_json::Value>>,
67    /// An alternative to sampling with temperature, called nucleus sampling, where the
68    #[serde(skip_serializing_if = "Option::is_none", default)]
69    pub top_p: Option<f64>,
70}
71
72/// The default strategy.
73#[derive(Debug, Clone, Serialize, Deserialize)]
74#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
75pub struct ToolResourcesFileSearchVectorStoreChunkingStrategyAuto {
76    /// Always `auto`.
77    #[serde(rename = "type")]
78    pub type_: String,
79}
80
81#[derive(Debug, Clone, Serialize, Deserialize)]
82#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
83pub struct ToolResourcesFileSearchVectorStoreChunkingStrategyStaticStatic {
84    /// The number of tokens that overlap between chunks. The default value is `400`.
85    pub chunk_overlap_tokens: i64,
86    /// The maximum number of tokens in each chunk.
87    pub max_chunk_size_tokens: i64,
88}
89
90#[derive(Debug, Clone, Serialize, Deserialize)]
91#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
92pub struct ToolResourcesFileSearchVectorStoreChunkingStrategyStatic {
93    #[serde(rename = "static")]
94    pub static_: ToolResourcesFileSearchVectorStoreChunkingStrategyStaticStatic,
95    /// Always `static`.
96    #[serde(rename = "type")]
97    pub type_: String,
98}
99
100pub type ToolResourcesFileSearchVectorStoreChunkingStrategy = serde_json::Value;
101
102#[derive(Debug, Clone, Serialize, Deserialize)]
103#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
104pub struct ToolResourcesFileSearchVectorStore {
105    /// The chunking strategy used to chunk the file(s).
106    #[serde(skip_serializing_if = "Option::is_none", default)]
107    pub chunking_strategy: Option<ToolResourcesFileSearchVectorStoreChunkingStrategy>,
108    /// A list of [file](https://platform.openai.com/docs/api-reference/files) IDs to
109    #[serde(skip_serializing_if = "Option::is_none", default)]
110    pub file_ids: Option<serde_json::Value>,
111    /// Set of 16 key-value pairs that can be attached to an object.
112    #[serde(skip_serializing_if = "Option::is_none", default)]
113    pub metadata: Option<serde_json::Value>,
114}
115
116#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
117#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
118#[non_exhaustive]
119pub enum AssistantListParamsOrder {
120    #[serde(rename = "asc")]
121    Asc,
122    #[serde(rename = "desc")]
123    Desc,
124}
125
126#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
127#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
128#[non_exhaustive]
129pub enum AssistantResponseFormatOption {
130    Auto,
131}
132
133/// Occurs when a new [thread](https://platform.openai.com/docs/api-reference/threads/object) is created.
134#[derive(Debug, Clone, Serialize, Deserialize)]
135#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
136pub struct ThreadCreated {
137    /// Represents a thread that contains
138    pub data: Thread,
139    pub event: String,
140    /// Whether to enable input audio transcription.
141    #[serde(skip_serializing_if = "Option::is_none", default)]
142    pub enabled: Option<bool>,
143}
144
145/// Occurs when a new [run](https://platform.openai.com/docs/api-reference/runs/object) is created.
146#[derive(Debug, Clone, Serialize, Deserialize)]
147#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
148pub struct ThreadRunCreated {
149    /// Represents an execution run on a
150    pub data: serde_json::Value,
151    pub event: String,
152}
153
154/// Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) moves to a `queued` status.
155#[derive(Debug, Clone, Serialize, Deserialize)]
156#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
157pub struct ThreadRunQueued {
158    /// Represents an execution run on a
159    pub data: serde_json::Value,
160    pub event: String,
161}
162
163/// Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) moves to an `in_progress` status.
164#[derive(Debug, Clone, Serialize, Deserialize)]
165#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
166pub struct ThreadRunInProgress {
167    /// Represents an execution run on a
168    pub data: serde_json::Value,
169    pub event: String,
170}
171
172/// Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) moves to a `requires_action` status.
173#[derive(Debug, Clone, Serialize, Deserialize)]
174#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
175pub struct ThreadRunRequiresAction {
176    /// Represents an execution run on a
177    pub data: serde_json::Value,
178    pub event: String,
179}
180
181/// Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) is completed.
182#[derive(Debug, Clone, Serialize, Deserialize)]
183#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
184pub struct ThreadRunCompleted {
185    /// Represents an execution run on a
186    pub data: serde_json::Value,
187    pub event: String,
188}
189
190/// Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) ends with status `incomplete`.
191#[derive(Debug, Clone, Serialize, Deserialize)]
192#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
193pub struct ThreadRunIncomplete {
194    /// Represents an execution run on a
195    pub data: serde_json::Value,
196    pub event: String,
197}
198
199/// Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) fails.
200#[derive(Debug, Clone, Serialize, Deserialize)]
201#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
202pub struct ThreadRunFailed {
203    /// Represents an execution run on a
204    pub data: serde_json::Value,
205    pub event: String,
206}
207
208/// Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) moves to a `cancelling` status.
209#[derive(Debug, Clone, Serialize, Deserialize)]
210#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
211pub struct ThreadRunCancelling {
212    /// Represents an execution run on a
213    pub data: serde_json::Value,
214    pub event: String,
215}
216
217/// Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) is cancelled.
218#[derive(Debug, Clone, Serialize, Deserialize)]
219#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
220pub struct ThreadRunCancelled {
221    /// Represents an execution run on a
222    pub data: serde_json::Value,
223    pub event: String,
224}
225
226/// Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) expires.
227#[derive(Debug, Clone, Serialize, Deserialize)]
228#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
229pub struct ThreadRunExpired {
230    /// Represents an execution run on a
231    pub data: serde_json::Value,
232    pub event: String,
233}
234
235/// Occurs when a [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object) is created.
236#[derive(Debug, Clone, Serialize, Deserialize)]
237#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
238pub struct ThreadRunStepCreated {
239    /// Represents a step in execution of a run.
240    pub data: serde_json::Value,
241    pub event: String,
242}
243
244/// Occurs when a [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object) moves to an `in_progress` state.
245#[derive(Debug, Clone, Serialize, Deserialize)]
246#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
247pub struct ThreadRunStepInProgress {
248    /// Represents a step in execution of a run.
249    pub data: serde_json::Value,
250    pub event: String,
251}
252
253/// Occurs when parts of a [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object) are being streamed.
254#[derive(Debug, Clone, Serialize, Deserialize)]
255#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
256pub struct ThreadRunStepDelta {
257    /// Represents a run step delta i.e.
258    pub data: serde_json::Value,
259    pub event: String,
260}
261
262/// Occurs when a [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object) is completed.
263#[derive(Debug, Clone, Serialize, Deserialize)]
264#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
265pub struct ThreadRunStepCompleted {
266    /// Represents a step in execution of a run.
267    pub data: serde_json::Value,
268    pub event: String,
269}
270
271/// Occurs when a [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object) fails.
272#[derive(Debug, Clone, Serialize, Deserialize)]
273#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
274pub struct ThreadRunStepFailed {
275    /// Represents a step in execution of a run.
276    pub data: serde_json::Value,
277    pub event: String,
278}
279
280/// Occurs when a [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object) is cancelled.
281#[derive(Debug, Clone, Serialize, Deserialize)]
282#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
283pub struct ThreadRunStepCancelled {
284    /// Represents a step in execution of a run.
285    pub data: serde_json::Value,
286    pub event: String,
287}
288
289/// Occurs when a [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object) expires.
290#[derive(Debug, Clone, Serialize, Deserialize)]
291#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
292pub struct ThreadRunStepExpired {
293    /// Represents a step in execution of a run.
294    pub data: serde_json::Value,
295    pub event: String,
296}
297
298/// Occurs when a [message](https://platform.openai.com/docs/api-reference/messages/object) is created.
299#[derive(Debug, Clone, Serialize, Deserialize)]
300#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
301pub struct ThreadMessageCreated {
302    /// Represents a message within a
303    pub data: Message,
304    pub event: String,
305}
306
307/// Occurs when a [message](https://platform.openai.com/docs/api-reference/messages/object) moves to an `in_progress` state.
308#[derive(Debug, Clone, Serialize, Deserialize)]
309#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
310pub struct ThreadMessageInProgress {
311    /// Represents a message within a
312    pub data: Message,
313    pub event: String,
314}
315
316/// Occurs when parts of a [Message](https://platform.openai.com/docs/api-reference/messages/object) are being streamed.
317#[derive(Debug, Clone, Serialize, Deserialize)]
318#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
319pub struct ThreadMessageDelta {
320    /// Represents a message delta i.e.
321    pub data: serde_json::Value,
322    pub event: String,
323}
324
325/// Occurs when a [message](https://platform.openai.com/docs/api-reference/messages/object) is completed.
326#[derive(Debug, Clone, Serialize, Deserialize)]
327#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
328pub struct ThreadMessageCompleted {
329    /// Represents a message within a
330    pub data: Message,
331    pub event: String,
332}
333
334/// Occurs when a [message](https://platform.openai.com/docs/api-reference/messages/object) ends before it is completed.
335#[derive(Debug, Clone, Serialize, Deserialize)]
336#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
337pub struct ThreadMessageIncomplete {
338    /// Represents a message within a
339    pub data: Message,
340    pub event: String,
341}
342
343/// Occurs when an [error](https://platform.openai.com/docs/guides/error-codes#api-errors) occurs. This can happen due to an internal server error or a timeout.
344#[derive(Debug, Clone, Serialize, Deserialize)]
345#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
346pub struct ErrorEvent {
347    pub data: serde_json::Value,
348    pub event: String,
349}
350
351pub type AssistantStreamEvent = serde_json::Value;
352
353pub type AssistantTool = serde_json::Value;
354
355#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
356#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
357#[non_exhaustive]
358pub enum AssistantToolChoiceType {
359    #[serde(rename = "function")]
360    Function,
361    #[serde(rename = "code_interpreter")]
362    CodeInterpreter,
363    #[serde(rename = "file_search")]
364    FileSearch,
365}
366
367/// Specifies a tool the model should use.
368#[derive(Debug, Clone, Serialize, Deserialize)]
369#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
370pub struct AssistantToolChoice {
371    /// The type of the tool. If type is `function`, the function name must be set
372    #[serde(rename = "type")]
373    pub type_: AssistantToolChoiceType,
374    #[serde(skip_serializing_if = "Option::is_none", default)]
375    pub function: Option<AssistantToolChoiceFunction>,
376}
377
378#[derive(Debug, Clone, Serialize, Deserialize)]
379#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
380pub struct AssistantToolChoiceFunction {
381    /// The name of the function to call.
382    pub name: String,
383}
384
385#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
386#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
387#[non_exhaustive]
388pub enum AssistantToolChoiceOption {
389    None,
390    Auto,
391    Required,
392}
393
394#[derive(Debug, Clone, Serialize, Deserialize)]
395#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
396pub struct AssistantUpdateParams {
397    /// The description of the assistant. The maximum length is 512 characters.
398    #[serde(skip_serializing_if = "Option::is_none", default)]
399    pub description: Option<String>,
400    /// The system instructions that the assistant uses.
401    #[serde(skip_serializing_if = "Option::is_none", default)]
402    pub instructions: Option<String>,
403    /// Set of 16 key-value pairs that can be attached to an object.
404    #[serde(skip_serializing_if = "Option::is_none", default)]
405    pub metadata: Option<serde_json::Value>,
406    /// ID of the model to use.
407    #[serde(skip_serializing_if = "Option::is_none", default)]
408    pub model: Option<String>,
409    /// The name of the assistant. The maximum length is 256 characters.
410    #[serde(skip_serializing_if = "Option::is_none", default)]
411    pub name: Option<String>,
412    /// Constrains effort on reasoning for
413    #[serde(skip_serializing_if = "Option::is_none", default)]
414    pub reasoning_effort: Option<serde_json::Value>,
415    /// Specifies the format that the model must output.
416    #[serde(skip_serializing_if = "Option::is_none", default)]
417    pub response_format: Option<serde_json::Value>,
418    /// What sampling temperature to use, between 0 and 2.
419    #[serde(skip_serializing_if = "Option::is_none", default)]
420    pub temperature: Option<f64>,
421    /// A set of resources that are used by the assistant's tools.
422    #[serde(skip_serializing_if = "Option::is_none", default)]
423    pub tool_resources: Option<ToolResources>,
424    /// A list of tool enabled on the assistant.
425    #[serde(skip_serializing_if = "Option::is_none", default)]
426    pub tools: Option<Vec<serde_json::Value>>,
427    /// An alternative to sampling with temperature, called nucleus sampling, where the
428    #[serde(skip_serializing_if = "Option::is_none", default)]
429    pub top_p: Option<f64>,
430}
431
432/// Tracing settings applied to the workflow.
433#[derive(Debug, Clone, Serialize, Deserialize)]
434#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
435pub struct Tracing {
436    /// Indicates whether tracing is enabled.
437    pub enabled: bool,
438}
439
440/// Workflow metadata and state returned for the session.
441#[derive(Debug, Clone, Serialize, Deserialize)]
442#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
443pub struct ChatKitWorkflow {
444    /// Identifier of the workflow backing the session.
445    pub id: String,
446    /// State variable key-value pairs applied when invoking the workflow.
447    #[serde(skip_serializing_if = "Option::is_none", default)]
448    pub state_variables: Option<std::collections::HashMap<String, serde_json::Value>>,
449    /// Tracing settings applied to the workflow.
450    pub tracing: Tracing,
451    /// Specific workflow version used for the session.
452    #[serde(skip_serializing_if = "Option::is_none", default)]
453    pub version: Option<String>,
454}
455
456#[derive(Debug, Clone, Serialize, Deserialize)]
457#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
458pub struct CodeInterpreterTool {
459    /// The type of tool being defined: `code_interpreter`
460    #[serde(rename = "type")]
461    pub type_: String,
462}
463
464#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
465#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
466#[non_exhaustive]
467pub enum FileSearchRankingOptionsRanker {
468    #[serde(rename = "auto")]
469    Auto,
470    #[serde(rename = "default_2024_08_21")]
471    Default20240821,
472}
473
474/// Overrides for the file search tool.
475#[derive(Debug, Clone, Serialize, Deserialize)]
476#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
477pub struct FileSearch {
478    /// The maximum number of results the file search tool should output.
479    #[serde(skip_serializing_if = "Option::is_none", default)]
480    pub max_num_results: Option<i64>,
481    /// The ranking options for the file search.
482    #[serde(skip_serializing_if = "Option::is_none", default)]
483    pub ranking_options: Option<FileSearchRankingOptions>,
484}
485
486#[derive(Debug, Clone, Serialize, Deserialize)]
487#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
488pub struct FileSearchTool {
489    /// The type of tool being defined: `file_search`
490    #[serde(rename = "type")]
491    pub type_: String,
492    /// Overrides for the file search tool.
493    #[serde(skip_serializing_if = "Option::is_none", default)]
494    pub file_search: Option<FileSearch>,
495}
496
497#[derive(Debug, Clone, Serialize, Deserialize)]
498#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
499pub struct FunctionTool {
500    pub function: serde_json::Value,
501    /// The type of tool being defined: `function`
502    #[serde(rename = "type")]
503    pub type_: String,
504}
505
506#[derive(Debug, Clone, Serialize, Deserialize)]
507#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
508pub struct ThreadCreateAndRunParamsBase {
509    /// The ID of the
510    pub assistant_id: String,
511    /// Override the default system message of the assistant.
512    #[serde(skip_serializing_if = "Option::is_none", default)]
513    pub instructions: Option<String>,
514    /// The maximum number of completion tokens that may be used over the course of the
515    #[serde(skip_serializing_if = "Option::is_none", default)]
516    pub max_completion_tokens: Option<i64>,
517    /// The maximum number of prompt tokens that may be used over the course of the run.
518    #[serde(skip_serializing_if = "Option::is_none", default)]
519    pub max_prompt_tokens: Option<i64>,
520    /// Set of 16 key-value pairs that can be attached to an object.
521    #[serde(skip_serializing_if = "Option::is_none", default)]
522    pub metadata: Option<serde_json::Value>,
523    /// The ID of the [Model](https://platform.openai.com/docs/api-reference/models) to
524    #[serde(skip_serializing_if = "Option::is_none", default)]
525    pub model: Option<String>,
526    /// Whether to enable
527    #[serde(skip_serializing_if = "Option::is_none", default)]
528    pub parallel_tool_calls: Option<bool>,
529    /// Specifies the format that the model must output.
530    #[serde(skip_serializing_if = "Option::is_none", default)]
531    pub response_format: Option<serde_json::Value>,
532    /// What sampling temperature to use, between 0 and 2.
533    #[serde(skip_serializing_if = "Option::is_none", default)]
534    pub temperature: Option<f64>,
535    /// Options to create a new thread.
536    #[serde(skip_serializing_if = "Option::is_none", default)]
537    pub thread: Option<Thread>,
538    /// Controls which (if any) tool is called by the model. `none` means the model will
539    #[serde(skip_serializing_if = "Option::is_none", default)]
540    pub tool_choice: Option<serde_json::Value>,
541    /// A set of resources that are used by the assistant's tools.
542    #[serde(skip_serializing_if = "Option::is_none", default)]
543    pub tool_resources: Option<ToolResources>,
544    /// Override the tools the assistant can use for this run.
545    #[serde(skip_serializing_if = "Option::is_none", default)]
546    pub tools: Option<Vec<serde_json::Value>>,
547    /// An alternative to sampling with temperature, called nucleus sampling, where the
548    #[serde(skip_serializing_if = "Option::is_none", default)]
549    pub top_p: Option<f64>,
550    /// Controls for how a thread will be truncated prior to the run.
551    #[serde(skip_serializing_if = "Option::is_none", default)]
552    pub truncation_strategy: Option<TruncationStrategy>,
553}
554
555#[derive(Debug, Clone, Serialize, Deserialize)]
556#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
557pub struct ThreadMessageAttachmentToolFileSearch {
558    /// The type of tool being defined: `file_search`
559    #[serde(rename = "type")]
560    pub type_: String,
561}
562
563pub type ThreadMessageAttachmentTool = serde_json::Value;
564
565#[derive(Debug, Clone, Serialize, Deserialize)]
566#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
567pub struct ThreadMessageAttachment {
568    /// The ID of the file to attach to the message.
569    #[serde(skip_serializing_if = "Option::is_none", default)]
570    pub file_id: Option<String>,
571    /// The tools to add this file to.
572    #[serde(skip_serializing_if = "Option::is_none", default)]
573    pub tools: Option<Vec<ThreadMessageAttachmentTool>>,
574}
575
576#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
577#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
578#[non_exhaustive]
579pub enum ThreadMessageRole {
580    #[serde(rename = "user")]
581    User,
582    #[serde(rename = "assistant")]
583    Assistant,
584}
585
586#[derive(Debug, Clone, Serialize, Deserialize)]
587#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
588pub struct ThreadToolResourcesCodeInterpreter {
589    /// A list of [file](https://platform.openai.com/docs/api-reference/files) IDs made
590    #[serde(skip_serializing_if = "Option::is_none", default)]
591    pub file_ids: Option<serde_json::Value>,
592}
593
594/// The default strategy.
595#[derive(Debug, Clone, Serialize, Deserialize)]
596#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
597pub struct ThreadToolResourcesFileSearchVectorStoreChunkingStrategyAuto {
598    /// Always `auto`.
599    #[serde(rename = "type")]
600    pub type_: String,
601}
602
603#[derive(Debug, Clone, Serialize, Deserialize)]
604#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
605pub struct ThreadToolResourcesFileSearchVectorStoreChunkingStrategyStaticStatic {
606    /// The number of tokens that overlap between chunks. The default value is `400`.
607    pub chunk_overlap_tokens: i64,
608    /// The maximum number of tokens in each chunk.
609    pub max_chunk_size_tokens: i64,
610}
611
612#[derive(Debug, Clone, Serialize, Deserialize)]
613#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
614pub struct ThreadToolResourcesFileSearchVectorStoreChunkingStrategyStatic {
615    #[serde(rename = "static")]
616    pub static_: ThreadToolResourcesFileSearchVectorStoreChunkingStrategyStaticStatic,
617    /// Always `static`.
618    #[serde(rename = "type")]
619    pub type_: String,
620}
621
622pub type ThreadToolResourcesFileSearchVectorStoreChunkingStrategy = serde_json::Value;
623
624#[derive(Debug, Clone, Serialize, Deserialize)]
625#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
626pub struct ThreadToolResourcesFileSearchVectorStore {
627    /// The chunking strategy used to chunk the file(s).
628    #[serde(skip_serializing_if = "Option::is_none", default)]
629    pub chunking_strategy: Option<ThreadToolResourcesFileSearchVectorStoreChunkingStrategy>,
630    /// A list of [file](https://platform.openai.com/docs/api-reference/files) IDs to
631    #[serde(skip_serializing_if = "Option::is_none", default)]
632    pub file_ids: Option<serde_json::Value>,
633    /// Set of 16 key-value pairs that can be attached to an object.
634    #[serde(skip_serializing_if = "Option::is_none", default)]
635    pub metadata: Option<serde_json::Value>,
636}
637
638#[derive(Debug, Clone, Serialize, Deserialize)]
639#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
640pub struct ThreadToolResourcesFileSearch {
641    /// The
642    #[serde(skip_serializing_if = "Option::is_none", default)]
643    pub vector_store_ids: Option<serde_json::Value>,
644    /// A helper to create a
645    #[serde(skip_serializing_if = "Option::is_none", default)]
646    pub vector_stores: Option<Vec<ThreadToolResourcesFileSearchVectorStore>>,
647}
648
649/// A set of resources that are made available to the assistant's tools in this thread. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs.
650#[derive(Debug, Clone, Serialize, Deserialize)]
651#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
652pub struct ThreadToolResources {
653    #[serde(skip_serializing_if = "Option::is_none", default)]
654    pub code_interpreter: Option<ThreadToolResourcesCodeInterpreter>,
655    #[serde(skip_serializing_if = "Option::is_none", default)]
656    pub file_search: Option<ThreadToolResourcesFileSearch>,
657}
658
659#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
660#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
661#[non_exhaustive]
662pub enum TruncationStrategyType {
663    #[serde(rename = "auto")]
664    Auto,
665    #[serde(rename = "last_messages")]
666    LastMessages,
667}
668
669/// Controls for how a thread will be truncated prior to the run.
670#[derive(Debug, Clone, Serialize, Deserialize)]
671#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
672pub struct TruncationStrategy {
673    /// The truncation strategy to use for the thread.
674    #[serde(rename = "type")]
675    pub type_: TruncationStrategyType,
676    /// The number of most recent messages from the thread when constructing the context
677    #[serde(skip_serializing_if = "Option::is_none", default)]
678    pub last_messages: Option<i64>,
679}
680
681pub type ThreadCreateAndRunParams = serde_json::Value;
682
683#[derive(Debug, Clone, Serialize, Deserialize)]
684#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
685pub struct ThreadCreateParams {
686    /// A list of [messages](https://platform.openai.com/docs/api-reference/messages) to
687    #[serde(skip_serializing_if = "Option::is_none", default)]
688    pub messages: Option<Vec<Message>>,
689    /// Set of 16 key-value pairs that can be attached to an object.
690    #[serde(skip_serializing_if = "Option::is_none", default)]
691    pub metadata: Option<serde_json::Value>,
692    /// A set of resources that are made available to the assistant's tools in this
693    #[serde(skip_serializing_if = "Option::is_none", default)]
694    pub tool_resources: Option<ToolResources>,
695}
696
697#[derive(Debug, Clone, Serialize, Deserialize)]
698#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
699pub struct MessageAttachmentToolFileSearch {
700    /// The type of tool being defined: `file_search`
701    #[serde(rename = "type")]
702    pub type_: String,
703}
704
705pub type MessageAttachmentTool = serde_json::Value;
706
707#[derive(Debug, Clone, Serialize, Deserialize)]
708#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
709pub struct MessageAttachment {
710    /// The ID of the file to attach to the message.
711    #[serde(skip_serializing_if = "Option::is_none", default)]
712    pub file_id: Option<String>,
713    /// The tools to add this file to.
714    #[serde(skip_serializing_if = "Option::is_none", default)]
715    pub tools: Option<Vec<MessageAttachmentTool>>,
716}
717
718#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
719#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
720#[non_exhaustive]
721pub enum MessageRole {
722    #[serde(rename = "user")]
723    User,
724    #[serde(rename = "assistant")]
725    Assistant,
726}
727
728#[derive(Debug, Clone, Serialize, Deserialize)]
729#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
730pub struct ThreadUpdateParams {
731    /// Set of 16 key-value pairs that can be attached to an object.
732    #[serde(skip_serializing_if = "Option::is_none", default)]
733    pub metadata: Option<serde_json::Value>,
734    /// A set of resources that are made available to the assistant's tools in this
735    #[serde(skip_serializing_if = "Option::is_none", default)]
736    pub tool_resources: Option<ToolResources>,
737}