openai-types 0.1.3

Typed OpenAI API models — zero dependencies beyond serde
Documentation
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
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
// AUTO-GENERATED by py2rust — do not edit.
// Re-generate: python3 scripts/py2rust.py sync <python_dir> <rust_dir>
// Domain: beta
#![allow(unused_imports)]

use serde::{Deserialize, Serialize};
use super::*;

#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct ToolResourcesCodeInterpreter {
    /// A list of [file](https://platform.openai.com/docs/api-reference/files) IDs made
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub file_ids: Option<Vec<String>>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct ToolResourcesFileSearch {
    /// The ID of the
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub vector_store_ids: Option<Vec<String>>,
}

/// A set of resources that are used by the assistant's tools.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct ToolResources {
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub code_interpreter: Option<ToolResourcesCodeInterpreter>,
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub file_search: Option<ToolResourcesFileSearch>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct AssistantCreateParams {
    /// ID of the model to use.
    pub model: String,
    /// The description of the assistant. The maximum length is 512 characters.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub description: Option<String>,
    /// The system instructions that the assistant uses.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub instructions: Option<String>,
    /// Set of 16 key-value pairs that can be attached to an object.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub metadata: Option<serde_json::Value>,
    /// The name of the assistant. The maximum length is 256 characters.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub name: Option<String>,
    /// Constrains effort on reasoning for
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub reasoning_effort: Option<serde_json::Value>,
    /// Specifies the format that the model must output.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub response_format: Option<serde_json::Value>,
    /// What sampling temperature to use, between 0 and 2.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub temperature: Option<f64>,
    /// A set of resources that are used by the assistant's tools.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub tool_resources: Option<ToolResources>,
    /// A list of tool enabled on the assistant.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub tools: Option<Vec<serde_json::Value>>,
    /// An alternative to sampling with temperature, called nucleus sampling, where the
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub top_p: Option<f64>,
}

/// The default strategy.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct ToolResourcesFileSearchVectorStoreChunkingStrategyAuto {
    /// Always `auto`.
    #[serde(rename = "type")]
    pub type_: String,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct ToolResourcesFileSearchVectorStoreChunkingStrategyStaticStatic {
    /// The number of tokens that overlap between chunks. The default value is `400`.
    pub chunk_overlap_tokens: i64,
    /// The maximum number of tokens in each chunk.
    pub max_chunk_size_tokens: i64,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct ToolResourcesFileSearchVectorStoreChunkingStrategyStatic {
    #[serde(rename = "static")]
    pub static_: ToolResourcesFileSearchVectorStoreChunkingStrategyStaticStatic,
    /// Always `static`.
    #[serde(rename = "type")]
    pub type_: String,
}

pub type ToolResourcesFileSearchVectorStoreChunkingStrategy = serde_json::Value;

#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct ToolResourcesFileSearchVectorStore {
    /// The chunking strategy used to chunk the file(s).
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub chunking_strategy: Option<ToolResourcesFileSearchVectorStoreChunkingStrategy>,
    /// A list of [file](https://platform.openai.com/docs/api-reference/files) IDs to
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub file_ids: Option<serde_json::Value>,
    /// Set of 16 key-value pairs that can be attached to an object.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub metadata: Option<serde_json::Value>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
#[non_exhaustive]
pub enum AssistantListParamsOrder {
    #[serde(rename = "asc")]
    Asc,
    #[serde(rename = "desc")]
    Desc,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
#[non_exhaustive]
pub enum AssistantResponseFormatOption {
    Auto,
}

/// Occurs when a new [thread](https://platform.openai.com/docs/api-reference/threads/object) is created.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct ThreadCreated {
    /// Represents a thread that contains
    pub data: Thread,
    pub event: String,
    /// Whether to enable input audio transcription.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub enabled: Option<bool>,
}

/// Occurs when a new [run](https://platform.openai.com/docs/api-reference/runs/object) is created.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct ThreadRunCreated {
    /// Represents an execution run on a
    pub data: serde_json::Value,
    pub event: String,
}

/// Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) moves to a `queued` status.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct ThreadRunQueued {
    /// Represents an execution run on a
    pub data: serde_json::Value,
    pub event: String,
}

/// Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) moves to an `in_progress` status.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct ThreadRunInProgress {
    /// Represents an execution run on a
    pub data: serde_json::Value,
    pub event: String,
}

/// Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) moves to a `requires_action` status.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct ThreadRunRequiresAction {
    /// Represents an execution run on a
    pub data: serde_json::Value,
    pub event: String,
}

/// Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) is completed.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct ThreadRunCompleted {
    /// Represents an execution run on a
    pub data: serde_json::Value,
    pub event: String,
}

/// Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) ends with status `incomplete`.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct ThreadRunIncomplete {
    /// Represents an execution run on a
    pub data: serde_json::Value,
    pub event: String,
}

/// Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) fails.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct ThreadRunFailed {
    /// Represents an execution run on a
    pub data: serde_json::Value,
    pub event: String,
}

/// Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) moves to a `cancelling` status.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct ThreadRunCancelling {
    /// Represents an execution run on a
    pub data: serde_json::Value,
    pub event: String,
}

/// Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) is cancelled.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct ThreadRunCancelled {
    /// Represents an execution run on a
    pub data: serde_json::Value,
    pub event: String,
}

/// Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) expires.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct ThreadRunExpired {
    /// Represents an execution run on a
    pub data: serde_json::Value,
    pub event: String,
}

/// Occurs when a [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object) is created.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct ThreadRunStepCreated {
    /// Represents a step in execution of a run.
    pub data: serde_json::Value,
    pub event: String,
}

/// Occurs when a [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object) moves to an `in_progress` state.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct ThreadRunStepInProgress {
    /// Represents a step in execution of a run.
    pub data: serde_json::Value,
    pub event: String,
}

/// Occurs when parts of a [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object) are being streamed.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct ThreadRunStepDelta {
    /// Represents a run step delta i.e.
    pub data: serde_json::Value,
    pub event: String,
}

/// Occurs when a [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object) is completed.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct ThreadRunStepCompleted {
    /// Represents a step in execution of a run.
    pub data: serde_json::Value,
    pub event: String,
}

/// Occurs when a [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object) fails.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct ThreadRunStepFailed {
    /// Represents a step in execution of a run.
    pub data: serde_json::Value,
    pub event: String,
}

/// Occurs when a [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object) is cancelled.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct ThreadRunStepCancelled {
    /// Represents a step in execution of a run.
    pub data: serde_json::Value,
    pub event: String,
}

/// Occurs when a [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object) expires.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct ThreadRunStepExpired {
    /// Represents a step in execution of a run.
    pub data: serde_json::Value,
    pub event: String,
}

/// Occurs when a [message](https://platform.openai.com/docs/api-reference/messages/object) is created.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct ThreadMessageCreated {
    /// Represents a message within a
    pub data: Message,
    pub event: String,
}

/// Occurs when a [message](https://platform.openai.com/docs/api-reference/messages/object) moves to an `in_progress` state.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct ThreadMessageInProgress {
    /// Represents a message within a
    pub data: Message,
    pub event: String,
}

/// Occurs when parts of a [Message](https://platform.openai.com/docs/api-reference/messages/object) are being streamed.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct ThreadMessageDelta {
    /// Represents a message delta i.e.
    pub data: serde_json::Value,
    pub event: String,
}

/// Occurs when a [message](https://platform.openai.com/docs/api-reference/messages/object) is completed.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct ThreadMessageCompleted {
    /// Represents a message within a
    pub data: Message,
    pub event: String,
}

/// Occurs when a [message](https://platform.openai.com/docs/api-reference/messages/object) ends before it is completed.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct ThreadMessageIncomplete {
    /// Represents a message within a
    pub data: Message,
    pub event: String,
}

/// 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.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct ErrorEvent {
    pub data: serde_json::Value,
    pub event: String,
}

pub type AssistantStreamEvent = serde_json::Value;

pub type AssistantTool = serde_json::Value;

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
#[non_exhaustive]
pub enum AssistantToolChoiceType {
    #[serde(rename = "function")]
    Function,
    #[serde(rename = "code_interpreter")]
    CodeInterpreter,
    #[serde(rename = "file_search")]
    FileSearch,
}

/// Specifies a tool the model should use.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct AssistantToolChoice {
    /// The type of the tool. If type is `function`, the function name must be set
    #[serde(rename = "type")]
    pub type_: AssistantToolChoiceType,
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub function: Option<AssistantToolChoiceFunction>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct AssistantToolChoiceFunction {
    /// The name of the function to call.
    pub name: String,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
#[non_exhaustive]
pub enum AssistantToolChoiceOption {
    None,
    Auto,
    Required,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct AssistantUpdateParams {
    /// The description of the assistant. The maximum length is 512 characters.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub description: Option<String>,
    /// The system instructions that the assistant uses.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub instructions: Option<String>,
    /// Set of 16 key-value pairs that can be attached to an object.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub metadata: Option<serde_json::Value>,
    /// ID of the model to use.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub model: Option<String>,
    /// The name of the assistant. The maximum length is 256 characters.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub name: Option<String>,
    /// Constrains effort on reasoning for
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub reasoning_effort: Option<serde_json::Value>,
    /// Specifies the format that the model must output.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub response_format: Option<serde_json::Value>,
    /// What sampling temperature to use, between 0 and 2.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub temperature: Option<f64>,
    /// A set of resources that are used by the assistant's tools.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub tool_resources: Option<ToolResources>,
    /// A list of tool enabled on the assistant.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub tools: Option<Vec<serde_json::Value>>,
    /// An alternative to sampling with temperature, called nucleus sampling, where the
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub top_p: Option<f64>,
}

/// Tracing settings applied to the workflow.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct Tracing {
    /// Indicates whether tracing is enabled.
    pub enabled: bool,
}

/// Workflow metadata and state returned for the session.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct ChatKitWorkflow {
    /// Identifier of the workflow backing the session.
    pub id: String,
    /// State variable key-value pairs applied when invoking the workflow.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub state_variables: Option<std::collections::HashMap<String, serde_json::Value>>,
    /// Tracing settings applied to the workflow.
    pub tracing: Tracing,
    /// Specific workflow version used for the session.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub version: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct CodeInterpreterTool {
    /// The type of tool being defined: `code_interpreter`
    #[serde(rename = "type")]
    pub type_: String,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
#[non_exhaustive]
pub enum FileSearchRankingOptionsRanker {
    #[serde(rename = "auto")]
    Auto,
    #[serde(rename = "default_2024_08_21")]
    Default20240821,
}

/// Overrides for the file search tool.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct FileSearch {
    /// The maximum number of results the file search tool should output.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub max_num_results: Option<i64>,
    /// The ranking options for the file search.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub ranking_options: Option<FileSearchRankingOptions>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct FileSearchTool {
    /// The type of tool being defined: `file_search`
    #[serde(rename = "type")]
    pub type_: String,
    /// Overrides for the file search tool.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub file_search: Option<FileSearch>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct FunctionTool {
    pub function: serde_json::Value,
    /// The type of tool being defined: `function`
    #[serde(rename = "type")]
    pub type_: String,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct ThreadCreateAndRunParamsBase {
    /// The ID of the
    pub assistant_id: String,
    /// Override the default system message of the assistant.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub instructions: Option<String>,
    /// The maximum number of completion tokens that may be used over the course of the
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub max_completion_tokens: Option<i64>,
    /// The maximum number of prompt tokens that may be used over the course of the run.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub max_prompt_tokens: Option<i64>,
    /// Set of 16 key-value pairs that can be attached to an object.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub metadata: Option<serde_json::Value>,
    /// The ID of the [Model](https://platform.openai.com/docs/api-reference/models) to
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub model: Option<String>,
    /// Whether to enable
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub parallel_tool_calls: Option<bool>,
    /// Specifies the format that the model must output.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub response_format: Option<serde_json::Value>,
    /// What sampling temperature to use, between 0 and 2.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub temperature: Option<f64>,
    /// Options to create a new thread.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub thread: Option<Thread>,
    /// Controls which (if any) tool is called by the model. `none` means the model will
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub tool_choice: Option<serde_json::Value>,
    /// A set of resources that are used by the assistant's tools.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub tool_resources: Option<ToolResources>,
    /// Override the tools the assistant can use for this run.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub tools: Option<Vec<serde_json::Value>>,
    /// An alternative to sampling with temperature, called nucleus sampling, where the
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub top_p: Option<f64>,
    /// Controls for how a thread will be truncated prior to the run.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub truncation_strategy: Option<TruncationStrategy>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct ThreadMessageAttachmentToolFileSearch {
    /// The type of tool being defined: `file_search`
    #[serde(rename = "type")]
    pub type_: String,
}

pub type ThreadMessageAttachmentTool = serde_json::Value;

#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct ThreadMessageAttachment {
    /// The ID of the file to attach to the message.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub file_id: Option<String>,
    /// The tools to add this file to.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub tools: Option<Vec<ThreadMessageAttachmentTool>>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
#[non_exhaustive]
pub enum ThreadMessageRole {
    #[serde(rename = "user")]
    User,
    #[serde(rename = "assistant")]
    Assistant,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct ThreadToolResourcesCodeInterpreter {
    /// A list of [file](https://platform.openai.com/docs/api-reference/files) IDs made
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub file_ids: Option<serde_json::Value>,
}

/// The default strategy.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct ThreadToolResourcesFileSearchVectorStoreChunkingStrategyAuto {
    /// Always `auto`.
    #[serde(rename = "type")]
    pub type_: String,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct ThreadToolResourcesFileSearchVectorStoreChunkingStrategyStaticStatic {
    /// The number of tokens that overlap between chunks. The default value is `400`.
    pub chunk_overlap_tokens: i64,
    /// The maximum number of tokens in each chunk.
    pub max_chunk_size_tokens: i64,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct ThreadToolResourcesFileSearchVectorStoreChunkingStrategyStatic {
    #[serde(rename = "static")]
    pub static_: ThreadToolResourcesFileSearchVectorStoreChunkingStrategyStaticStatic,
    /// Always `static`.
    #[serde(rename = "type")]
    pub type_: String,
}

pub type ThreadToolResourcesFileSearchVectorStoreChunkingStrategy = serde_json::Value;

#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct ThreadToolResourcesFileSearchVectorStore {
    /// The chunking strategy used to chunk the file(s).
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub chunking_strategy: Option<ThreadToolResourcesFileSearchVectorStoreChunkingStrategy>,
    /// A list of [file](https://platform.openai.com/docs/api-reference/files) IDs to
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub file_ids: Option<serde_json::Value>,
    /// Set of 16 key-value pairs that can be attached to an object.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub metadata: Option<serde_json::Value>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct ThreadToolResourcesFileSearch {
    /// The
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub vector_store_ids: Option<serde_json::Value>,
    /// A helper to create a
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub vector_stores: Option<Vec<ThreadToolResourcesFileSearchVectorStore>>,
}

/// 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.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct ThreadToolResources {
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub code_interpreter: Option<ThreadToolResourcesCodeInterpreter>,
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub file_search: Option<ThreadToolResourcesFileSearch>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
#[non_exhaustive]
pub enum TruncationStrategyType {
    #[serde(rename = "auto")]
    Auto,
    #[serde(rename = "last_messages")]
    LastMessages,
}

/// Controls for how a thread will be truncated prior to the run.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct TruncationStrategy {
    /// The truncation strategy to use for the thread.
    #[serde(rename = "type")]
    pub type_: TruncationStrategyType,
    /// The number of most recent messages from the thread when constructing the context
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub last_messages: Option<i64>,
}

pub type ThreadCreateAndRunParams = serde_json::Value;

#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct ThreadCreateParams {
    /// A list of [messages](https://platform.openai.com/docs/api-reference/messages) to
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub messages: Option<Vec<Message>>,
    /// Set of 16 key-value pairs that can be attached to an object.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub metadata: Option<serde_json::Value>,
    /// A set of resources that are made available to the assistant's tools in this
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub tool_resources: Option<ToolResources>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct MessageAttachmentToolFileSearch {
    /// The type of tool being defined: `file_search`
    #[serde(rename = "type")]
    pub type_: String,
}

pub type MessageAttachmentTool = serde_json::Value;

#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct MessageAttachment {
    /// The ID of the file to attach to the message.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub file_id: Option<String>,
    /// The tools to add this file to.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub tools: Option<Vec<MessageAttachmentTool>>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
#[non_exhaustive]
pub enum MessageRole {
    #[serde(rename = "user")]
    User,
    #[serde(rename = "assistant")]
    Assistant,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct ThreadUpdateParams {
    /// Set of 16 key-value pairs that can be attached to an object.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub metadata: Option<serde_json::Value>,
    /// A set of resources that are made available to the assistant's tools in this
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub tool_resources: Option<ToolResources>,
}