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
/*
* OpenAI API
*
* The OpenAI REST API. Please see https://platform.openai.com/docs/api-reference for more details.
*
* The version of the OpenAPI document: 2.3.0
*
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
/// OpenAiFile : The `File` object represents a document that has been uploaded to OpenAI.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct OpenAiFile {
/// The file identifier, which can be referenced in the API endpoints.
#[serde(rename = "id")]
pub id: String,
/// The size of the file, in bytes.
#[serde(rename = "bytes")]
pub bytes: i32,
/// The Unix timestamp (in seconds) for when the file was created.
#[serde(rename = "created_at")]
pub created_at: i32,
/// The Unix timestamp (in seconds) for when the file will expire.
#[serde(rename = "expires_at", skip_serializing_if = "Option::is_none")]
pub expires_at: Option<i32>,
/// The name of the file.
#[serde(rename = "filename")]
pub filename: String,
/// The object type, which is always `file`.
#[serde(rename = "object")]
pub object: Object,
/// The intended purpose of the file. Supported values are `assistants`, `assistants_output`, `batch`, `batch_output`, `fine-tune`, `fine-tune-results`, `vision`, and `user_data`.
#[serde(rename = "purpose")]
pub purpose: Purpose,
/// Deprecated. The current status of the file, which can be either `uploaded`, `processed`, or `error`.
#[serde(rename = "status")]
pub status: Status,
/// Deprecated. For details on why a fine-tuning training file failed validation, see the `error` field on `fine_tuning.job`.
#[serde(rename = "status_details", skip_serializing_if = "Option::is_none")]
pub status_details: Option<String>,
}
impl OpenAiFile {
/// The `File` object represents a document that has been uploaded to OpenAI.
pub fn new(
id: String,
bytes: i32,
created_at: i32,
filename: String,
object: Object,
purpose: Purpose,
status: Status,
) -> OpenAiFile {
OpenAiFile {
id,
bytes,
created_at,
expires_at: None,
filename,
object,
purpose,
status,
status_details: None,
}
}
}
/// The object type, which is always `file`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Object {
#[serde(rename = "file")]
File,
}
impl Default for Object {
fn default() -> Object {
Self::File
}
}
/// The intended purpose of the file. Supported values are `assistants`, `assistants_output`, `batch`, `batch_output`, `fine-tune`, `fine-tune-results`, `vision`, and `user_data`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Purpose {
#[serde(rename = "assistants")]
Assistants,
#[serde(rename = "assistants_output")]
AssistantsOutput,
#[serde(rename = "batch")]
Batch,
#[serde(rename = "batch_output")]
BatchOutput,
#[serde(rename = "fine-tune")]
FineTune,
#[serde(rename = "fine-tune-results")]
FineTuneResults,
#[serde(rename = "vision")]
Vision,
#[serde(rename = "user_data")]
UserData,
}
impl Default for Purpose {
fn default() -> Purpose {
Self::Assistants
}
}
/// Deprecated. The current status of the file, which can be either `uploaded`, `processed`, or `error`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Status {
#[serde(rename = "uploaded")]
Uploaded,
#[serde(rename = "processed")]
Processed,
#[serde(rename = "error")]
Error,
}
impl Default for Status {
fn default() -> Status {
Self::Uploaded
}
}
impl std::fmt::Display for OpenAiFile {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match serde_json::to_string(self) {
Ok(s) => write!(f, "{}", s),
Err(_) => Err(std::fmt::Error),
}
}
}