Module fine_tunes

Source
Expand description

This module provides functionality for working with fine-tuning jobs using the OpenAI Fine-tunes API.

Fine-tuning allows you to train a model on custom data so it can better handle domain-specific terminology or style. You start by uploading training data as a file, and optionally a validation file. Then you create a fine-tune job pointing to those files. Once the job is finished, you can use the resulting fine-tuned model for completions or other tasks.

§Overview

  1. Upload training file (outside the scope of this module, see the Files API).
  2. Create a fine-tune job with create_fine_tune.
  3. List fine-tunes with list_fine_tunes.
  4. Retrieve a fine-tune with retrieve_fine_tune.
  5. Cancel a fine-tune with cancel_fine_tune, if needed.
  6. List fine-tune events with list_fine_tune_events (to see training progress).
  7. Delete fine-tuned model with delete_fine_tune_model, if you want to remove it.

§Example

use chat_gpt_lib_rs::api_resources::fine_tunes::{create_fine_tune, CreateFineTuneRequest};
use chat_gpt_lib_rs::error::OpenAIError;
use chat_gpt_lib_rs::OpenAIClient;

#[tokio::main]
async fn main() -> Result<(), OpenAIError> {
    let client = OpenAIClient::new(None)?; // Reads API key from OPENAI_API_KEY

    // Create a fine-tune job (assumes you've already uploaded a file and obtained its ID).
    let request = CreateFineTuneRequest {
        training_file: "file-abc123".to_string(),
        model: Some("curie".to_string()),
        ..Default::default()
    };

    let response = create_fine_tune(&client, &request).await?;
    println!("Created fine-tune: {}", response.id);

    Ok(())
}

Structs§

CreateFineTuneRequest
A request struct for creating a fine-tune job.
DeleteFineTuneModelResponse
Response returned after deleting a fine-tuned model.
FineTune
Represents a fine-tune job, either newly created or retrieved from the API.
FineTuneEvent
Represents a single event in a fine-tune job’s lifecycle (e.g., job enqueued, model trained).
FineTuneEventsList
A helper struct for deserializing the result of GET /v1/fine-tunes/{fine_tune_id}/events.
FineTuneList
The response for listing fine-tunes: an object with "data" containing an array of FineTune.

Functions§

cancel_fine_tune
Cancels a fine-tune job by its ID.
create_fine_tune
Creates a fine-tune job.
delete_fine_tune_model
Deletes a fine-tuned model (i.e., the actual model generated after successful fine-tuning).
list_fine_tune_events
Lists events for a given fine-tune job (useful for seeing training progress).
list_fine_tunes
Lists all fine-tune jobs associated with the user’s API key.
retrieve_fine_tune
Retrieves a fine-tune job by its ID (e.g. “ft-XXXXXXXX”).