/*
* 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};
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct CreateFineTuningJobRequest {
/// The name of the model to fine-tune. You can select one of the [supported models](/docs/guides/fine-tuning#which-models-can-be-fine-tuned).
#[serde(rename = "model")]
pub model: String,
/// The ID of an uploaded file that contains training data. See [upload file](/docs/api-reference/files/create) for how to upload a file. Your dataset must be formatted as a JSONL file. Additionally, you must upload your file with the purpose `fine-tune`. The contents of the file should differ depending on if the model uses the [chat](/docs/api-reference/fine-tuning/chat-input), [completions](/docs/api-reference/fine-tuning/completions-input) format, or if the fine-tuning method uses the [preference](/docs/api-reference/fine-tuning/preference-input) format. See the [fine-tuning guide](/docs/guides/model-optimization) for more details.
#[serde(rename = "training_file")]
pub training_file: String,
#[serde(rename = "hyperparameters", skip_serializing_if = "Option::is_none")]
pub hyperparameters: Option<Box<models::CreateFineTuningJobRequestHyperparameters>>,
/// A string of up to 64 characters that will be added to your fine-tuned model name. For example, a `suffix` of \"custom-model-name\" would produce a model name like `ft:gpt-4o-mini:openai:custom-model-name:7p4lURel`.
#[serde(rename = "suffix", skip_serializing_if = "Option::is_none")]
pub suffix: Option<String>,
/// The ID of an uploaded file that contains validation data. If you provide this file, the data is used to generate validation metrics periodically during fine-tuning. These metrics can be viewed in the fine-tuning results file. The same data should not be present in both train and validation files. Your dataset must be formatted as a JSONL file. You must upload your file with the purpose `fine-tune`. See the [fine-tuning guide](/docs/guides/model-optimization) for more details.
#[serde(rename = "validation_file", skip_serializing_if = "Option::is_none")]
pub validation_file: Option<String>,
/// A list of integrations to enable for your fine-tuning job.
#[serde(rename = "integrations", skip_serializing_if = "Option::is_none")]
pub integrations: Option<Vec<models::CreateFineTuningJobRequestIntegrationsInner>>,
/// The seed controls the reproducibility of the job. Passing in the same seed and job parameters should produce the same results, but may differ in rare cases. If a seed is not specified, one will be generated for you.
#[serde(rename = "seed", skip_serializing_if = "Option::is_none")]
pub seed: 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 CreateFineTuningJobRequest {
pub fn new(model: String, training_file: String) -> CreateFineTuningJobRequest {
CreateFineTuningJobRequest {
model,
training_file,
hyperparameters: None,
suffix: None,
validation_file: None,
integrations: None,
seed: None,
method: None,
metadata: None,
}
}
}
impl std::fmt::Display for CreateFineTuningJobRequest {
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),
}
}
}