All files / shared/src/types/api/routes/fine-tuning-api request.ts

100% Statements 47/47
100% Branches 0/0
100% Functions 0/0
100% Lines 47/47

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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 1351x         1x   1x   1x   1x 1x 1x 1x             1x   1x   1x   1x   1x   1x   1x 1x 1x             1x   1x   1x   1x   1x   1x   1x   1x   1x 1x                 1x   1x 1x                 1x   1x   1x 1x                 1x   1x 1x                 1x   1x   1x   1x 1x                 1x   1x   1x   1x 1x          
import { z } from 'zod';
 
/**
 * The hyperparameters used for the fine-tuning job.
 */
export const Hyperparameters = z.object({
  /** Number of epochs to train the model for. An epoch refers to one full cycle through the training dataset. */
  n_epochs: z.union([z.number().int().min(1).max(50), z.literal('auto')]),
  /** Batch size to use for training. The batch size is the number of training examples used to train a single forward and backward pass. */
  batch_size: z.union([z.number().int().min(1), z.literal('auto')]).optional(),
  /** Learning rate multiplier to use for training. */
  learning_rate_multiplier: z
    .union([z.number().positive(), z.literal('auto')])
    .optional(),
});
 
export type Hyperparameters = z.infer<typeof Hyperparameters>;
 
/**
 * Integration configuration for fine-tuning job.
 */
export const Integration = z.object({
  /** The type of integration to enable. Currently only "wandb" (Weights and Biases) is supported. */
  type: z.literal('wandb'),
  /** The Weights and Biases integration configuration. */
  wandb: z.object({
    /** The name of the project that the new run will be created under. */
    project: z.string(),
    /** A display name to set for the run. If not set, we will use the Job ID as the name. */
    name: z.string().optional(),
    /** The entity to use for the run. This allows you to set the team or username of the WandB user that you would like associated with the run. */
    entity: z.string().optional(),
    /** A list of tags to be attached to the newly created run. */
    tags: z.array(z.string()).optional(),
  }),
});
 
export type Integration = z.infer<typeof Integration>;
 
/**
 * The parameters for creating a fine-tuning job.
 */
export const CreateFineTuningJobRequestBody = z.object({
  /** The name of the model to fine-tune. You can select one of the supported models. */
  model: z.string(),
  /** The ID of an uploaded file that contains training data. */
  training_file: z.string(),
  /** The hyperparameters used for the fine-tuning job. */
  hyperparameters: Hyperparameters.optional(),
  /** A string of up to 18 characters that will be added to your fine-tuned model name. */
  suffix: z.string().max(18).optional(),
  /** The ID of an uploaded file that contains validation data. */
  validation_file: z.string().optional(),
  /** A list of integrations to enable for your fine-tuning job. */
  integrations: z.array(Integration).optional(),
  /** The seed controls the reproducibility of the job. */
  seed: z.number().int().optional(),
  /** Set of 16 key-value pairs that can be attached to an object. */
  metadata: z.record(z.string(), z.string()).optional(),
});
 
export type CreateFineTuningJobRequestBody = z.infer<
  typeof CreateFineTuningJobRequestBody
>;
 
/**
 * The parameters for retrieving a fine-tuning job.
 */
export const RetrieveFineTuningJobRequestBody = z.object({
  /** The ID of the fine-tuning job. */
  fine_tuning_job_id: z.string(),
});
 
export type RetrieveFineTuningJobRequestBody = z.infer<
  typeof RetrieveFineTuningJobRequestBody
>;
 
/**
 * The parameters for listing fine-tuning jobs.
 */
export const ListFineTuningJobsRequestBody = z.object({
  /** Identifier for the last job from the previous pagination request. */
  after: z.string().optional(),
  /** Number of fine-tuning jobs to retrieve. */
  limit: z.number().int().min(1).max(100).default(20).optional(),
});
 
export type ListFineTuningJobsRequestBody = z.infer<
  typeof ListFineTuningJobsRequestBody
>;
 
/**
 * The parameters for cancelling a fine-tuning job.
 */
export const CancelFineTuningJobRequestBody = z.object({
  /** The ID of the fine-tuning job to cancel. */
  fine_tuning_job_id: z.string(),
});
 
export type CancelFineTuningJobRequestBody = z.infer<
  typeof CancelFineTuningJobRequestBody
>;
 
/**
 * The parameters for listing fine-tuning events.
 */
export const ListFineTuningEventsRequestBody = z.object({
  /** The ID of the fine-tuning job to get events for. */
  fine_tuning_job_id: z.string(),
  /** Identifier for the last event from the previous pagination request. */
  after: z.string().optional(),
  /** Number of events to retrieve. */
  limit: z.number().int().min(1).max(100).default(20).optional(),
});
 
export type ListFineTuningEventsRequestBody = z.infer<
  typeof ListFineTuningEventsRequestBody
>;
 
/**
 * The parameters for listing fine-tuning checkpoints.
 */
export const ListFineTuningCheckpointsRequestBody = z.object({
  /** The ID of the fine-tuning job to get checkpoints for. */
  fine_tuning_job_id: z.string(),
  /** Identifier for the last checkpoint ID from the previous pagination request. */
  after: z.string().optional(),
  /** Number of checkpoints to retrieve. */
  limit: z.number().int().min(1).max(100).default(10).optional(),
});
 
export type ListFineTuningCheckpointsRequestBody = z.infer<
  typeof ListFineTuningCheckpointsRequestBody
>;