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
/*
* 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};
/// FineTuningJob : The `fine_tuning.job` object represents a fine-tuning job that has been created through the API.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct FineTuningJob {
/// The object identifier, which can be referenced in the API endpoints.
#[serde(rename = "id")]
pub id: String,
/// The Unix timestamp (in seconds) for when the fine-tuning job was created.
#[serde(rename = "created_at")]
pub created_at: i32,
#[serde(rename = "error", deserialize_with = "Option::deserialize")]
pub error: Option<Box<models::Object08>>,
/// The name of the fine-tuned model that is being created. The value will be null if the fine-tuning job is still running.
#[serde(rename = "fine_tuned_model", deserialize_with = "Option::deserialize")]
pub fine_tuned_model: Option<String>,
/// The Unix timestamp (in seconds) for when the fine-tuning job was finished. The value will be null if the fine-tuning job is still running.
#[serde(rename = "finished_at", deserialize_with = "Option::deserialize")]
pub finished_at: Option<i32>,
#[serde(rename = "hyperparameters")]
pub hyperparameters: Box<models::FineTuningJobHyperparameters>,
/// The base model that is being fine-tuned.
#[serde(rename = "model")]
pub model: String,
/// The object type, which is always \"fine_tuning.job\".
#[serde(rename = "object")]
pub object: Object,
/// The organization that owns the fine-tuning job.
#[serde(rename = "organization_id")]
pub organization_id: String,
/// The compiled results file ID(s) for the fine-tuning job. You can retrieve the results with the [Files API](/docs/api-reference/files/retrieve-contents).
#[serde(rename = "result_files")]
pub result_files: Vec<String>,
/// The current status of the fine-tuning job, which can be either `validating_files`, `queued`, `running`, `succeeded`, `failed`, or `cancelled`.
#[serde(rename = "status")]
pub status: Status,
/// The total number of billable tokens processed by this fine-tuning job. The value will be null if the fine-tuning job is still running.
#[serde(rename = "trained_tokens", deserialize_with = "Option::deserialize")]
pub trained_tokens: Option<i32>,
/// The file ID used for training. You can retrieve the training data with the [Files API](/docs/api-reference/files/retrieve-contents).
#[serde(rename = "training_file")]
pub training_file: String,
/// The file ID used for validation. You can retrieve the validation results with the [Files API](/docs/api-reference/files/retrieve-contents).
#[serde(rename = "validation_file", deserialize_with = "Option::deserialize")]
pub validation_file: Option<String>,
/// A list of integrations to enable for this fine-tuning job.
#[serde(
rename = "integrations",
default,
with = "::serde_with::rust::double_option",
skip_serializing_if = "Option::is_none"
)]
pub integrations: Option<Option<Vec<models::FineTuningIntegration>>>,
/// The seed used for the fine-tuning job.
#[serde(rename = "seed")]
pub seed: i32,
/// The Unix timestamp (in seconds) for when the fine-tuning job is estimated to finish. The value will be null if the fine-tuning job is not running.
#[serde(
rename = "estimated_finish",
default,
with = "::serde_with::rust::double_option",
skip_serializing_if = "Option::is_none"
)]
pub estimated_finish: Option<Option<i32>>,
#[serde(rename = "method", skip_serializing_if = "Option::is_none")]
pub method: Option<Box<models::FineTuneMethod>>,
/// Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard. Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters.
#[serde(
rename = "metadata",
default,
with = "::serde_with::rust::double_option",
skip_serializing_if = "Option::is_none"
)]
pub metadata: Option<Option<std::collections::HashMap<String, String>>>,
}
impl FineTuningJob {
/// The `fine_tuning.job` object represents a fine-tuning job that has been created through the API.
pub fn new(
id: String,
created_at: i32,
error: Option<models::Object08>,
fine_tuned_model: Option<String>,
finished_at: Option<i32>,
hyperparameters: models::FineTuningJobHyperparameters,
model: String,
object: Object,
organization_id: String,
result_files: Vec<String>,
status: Status,
trained_tokens: Option<i32>,
training_file: String,
validation_file: Option<String>,
seed: i32,
) -> FineTuningJob {
FineTuningJob {
id,
created_at,
error: error.map(Box::new),
fine_tuned_model,
finished_at,
hyperparameters: Box::new(hyperparameters),
model,
object,
organization_id,
result_files,
status,
trained_tokens,
training_file,
validation_file,
integrations: None,
seed,
estimated_finish: None,
method: None,
metadata: None,
}
}
}
/// The object type, which is always \"fine_tuning.job\".
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Object {
#[serde(rename = "fine_tuning.job")]
FineTuningJob,
}
impl Default for Object {
fn default() -> Object {
Self::FineTuningJob
}
}
/// The current status of the fine-tuning job, which can be either `validating_files`, `queued`, `running`, `succeeded`, `failed`, or `cancelled`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Status {
#[serde(rename = "validating_files")]
ValidatingFiles,
#[serde(rename = "queued")]
Queued,
#[serde(rename = "running")]
Running,
#[serde(rename = "succeeded")]
Succeeded,
#[serde(rename = "failed")]
Failed,
#[serde(rename = "cancelled")]
Cancelled,
}
impl Default for Status {
fn default() -> Status {
Self::ValidatingFiles
}
}
impl std::fmt::Display for FineTuningJob {
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),
}
}
}