Skip to content

Commit 3ffae34

Browse files
author
michal.zyga
committed
add cancel fine tuning job method
1 parent ca0330d commit 3ffae34

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

core/src/main/scala/sttp/openai/OpenAI.scala

+13
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,18 @@ class OpenAI(authToken: String, baseUri: Uri = OpenAIUris.OpenAIBaseUri) {
625625
.get(openAIUris.fineTuningJob(fineTuningJobId))
626626
.response(asJson_parseErrors[FineTuningJobResponse])
627627

628+
/** Immediately cancel a fine-tune job.
629+
*
630+
* [[https://platform.openai.com/docs/api-reference/fine-tuning/cancel]]
631+
*
632+
* @param fineTuningJobId
633+
* The ID of the fine-tuning job to cancel.
634+
*/
635+
def cancelFineTuningJob(fineTuningJobId: String): Request[Either[OpenAIException, FineTuningJobResponse]] =
636+
openAIAuthRequest
637+
.post(openAIUris.cancelFineTuningJob(fineTuningJobId))
638+
.response(asJson_parseErrors[FineTuningJobResponse])
639+
628640
/** Gets info about the fine-tune job.
629641
*
630642
* [[https://platform.openai.com/docs/api-reference/embeddings/create]]
@@ -1133,6 +1145,7 @@ private class OpenAIUris(val baseUri: Uri) {
11331145
def fineTuningJob(fineTuningJobId: String): Uri = FineTuningJobs.addPath(fineTuningJobId)
11341146
def fineTuningJobEvents(fineTuningJobId: String): Uri = fineTuningJob(fineTuningJobId).addPath("events")
11351147
def fineTuningJobCheckpoints(fineTuningJobId: String): Uri = fineTuningJob(fineTuningJobId).addPath("checkpoints")
1148+
def cancelFineTuningJob(fineTuningJobId: String): Uri = fineTuningJob(fineTuningJobId).addPath("cancel")
11361149

11371150
def file(fileId: String): Uri = Files.addPath(fileId)
11381151
def fileContent(fileId: String): Uri = Files.addPath(fileId, "content")

core/src/main/scala/sttp/openai/OpenAISyncClient.scala

+10
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,16 @@ class OpenAISyncClient private (
405405
def retrieveFineTuningJob(fineTuningJobId: String): FineTuningJobResponse =
406406
sendOrThrow(openAI.retrieveFineTuningJob(fineTuningJobId))
407407

408+
/** Immediately cancel a fine-tune job.
409+
*
410+
* [[https://platform.openai.com/docs/api-reference/fine-tuning/cancel]]
411+
*
412+
* @param fineTuningJobId
413+
* The ID of the fine-tuning job to cancel.
414+
*/
415+
def cancelFineTuningJob(fineTuningJobId: String): FineTuningJobResponse =
416+
sendOrThrow(openAI.cancelFineTuningJob(fineTuningJobId))
417+
408418
/** Gets info about the fine-tune job.
409419
*
410420
* [[https://platform.openai.com/docs/api-reference/embeddings/create]]

0 commit comments

Comments
 (0)