ModelAi/node_modules/openai/resources/fine-tuning/jobs/jobs.mjs
2025-09-15 10:04:47 +08:00

118 lines
3.6 KiB
JavaScript

// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from "../../../core/resource.mjs";
import * as CheckpointsAPI from "./checkpoints.mjs";
import { Checkpoints, } from "./checkpoints.mjs";
import { CursorPage } from "../../../core/pagination.mjs";
import { path } from "../../../internal/utils/path.mjs";
export class Jobs extends APIResource {
constructor() {
super(...arguments);
this.checkpoints = new CheckpointsAPI.Checkpoints(this._client);
}
/**
* Creates a fine-tuning job which begins the process of creating a new model from
* a given dataset.
*
* Response includes details of the enqueued job including job status and the name
* of the fine-tuned models once complete.
*
* [Learn more about fine-tuning](https://platform.openai.com/docs/guides/model-optimization)
*
* @example
* ```ts
* const fineTuningJob = await client.fineTuning.jobs.create({
* model: 'gpt-4o-mini',
* training_file: 'file-abc123',
* });
* ```
*/
create(body, options) {
return this._client.post('/fine_tuning/jobs', { body, ...options });
}
/**
* Get info about a fine-tuning job.
*
* [Learn more about fine-tuning](https://platform.openai.com/docs/guides/model-optimization)
*
* @example
* ```ts
* const fineTuningJob = await client.fineTuning.jobs.retrieve(
* 'ft-AF1WoRqd3aJAHsqc9NY7iL8F',
* );
* ```
*/
retrieve(fineTuningJobID, options) {
return this._client.get(path `/fine_tuning/jobs/${fineTuningJobID}`, options);
}
/**
* List your organization's fine-tuning jobs
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const fineTuningJob of client.fineTuning.jobs.list()) {
* // ...
* }
* ```
*/
list(query = {}, options) {
return this._client.getAPIList('/fine_tuning/jobs', (CursorPage), { query, ...options });
}
/**
* Immediately cancel a fine-tune job.
*
* @example
* ```ts
* const fineTuningJob = await client.fineTuning.jobs.cancel(
* 'ft-AF1WoRqd3aJAHsqc9NY7iL8F',
* );
* ```
*/
cancel(fineTuningJobID, options) {
return this._client.post(path `/fine_tuning/jobs/${fineTuningJobID}/cancel`, options);
}
/**
* Get status updates for a fine-tuning job.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const fineTuningJobEvent of client.fineTuning.jobs.listEvents(
* 'ft-AF1WoRqd3aJAHsqc9NY7iL8F',
* )) {
* // ...
* }
* ```
*/
listEvents(fineTuningJobID, query = {}, options) {
return this._client.getAPIList(path `/fine_tuning/jobs/${fineTuningJobID}/events`, (CursorPage), { query, ...options });
}
/**
* Pause a fine-tune job.
*
* @example
* ```ts
* const fineTuningJob = await client.fineTuning.jobs.pause(
* 'ft-AF1WoRqd3aJAHsqc9NY7iL8F',
* );
* ```
*/
pause(fineTuningJobID, options) {
return this._client.post(path `/fine_tuning/jobs/${fineTuningJobID}/pause`, options);
}
/**
* Resume a fine-tune job.
*
* @example
* ```ts
* const fineTuningJob = await client.fineTuning.jobs.resume(
* 'ft-AF1WoRqd3aJAHsqc9NY7iL8F',
* );
* ```
*/
resume(fineTuningJobID, options) {
return this._client.post(path `/fine_tuning/jobs/${fineTuningJobID}/resume`, options);
}
}
Jobs.Checkpoints = Checkpoints;
//# sourceMappingURL=jobs.mjs.map