Skip to content

Commit

Permalink
add hyperparameters arg to fine_tuning.jobs.create
Browse files Browse the repository at this point in the history
  • Loading branch information
aanaseer authored and RobertCraigie committed Mar 18, 2024
1 parent e286d0f commit b26a01a
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/openai/cli/_api/fine_tuning/jobs.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import json
from typing import TYPE_CHECKING
from argparse import ArgumentParser

Expand Down Expand Up @@ -30,6 +31,12 @@ def register(subparser: _SubParsersAction[ArgumentParser]) -> None:
help="The training file to fine-tune the model on.",
required=True,
)
sub.add_argument(
"-H",
"--hyperparameters",
help="JSON string of hyperparameters to use for fine-tuning.",
type=str,
)
sub.add_argument(
"-s",
"--suffix",
Expand Down Expand Up @@ -106,6 +113,7 @@ def register(subparser: _SubParsersAction[ArgumentParser]) -> None:
class CLIFineTuningJobsCreateArgs(BaseModel):
model: str
training_file: str
hyperparameters: NotGivenOr[str] = NOT_GIVEN
suffix: NotGivenOr[str] = NOT_GIVEN
validation_file: NotGivenOr[str] = NOT_GIVEN

Expand All @@ -128,14 +136,16 @@ class CLIFineTuningJobsListEventsArgs(BaseModel):
class CLIFineTuningJobs:
@staticmethod
def create(args: CLIFineTuningJobsCreateArgs) -> None:
hyperparameters = json.loads(args.hyperparameters) if args.hyperparameters is not NOT_GIVEN else NOT_GIVEN
fine_tuning_job: FineTuningJob = get_client().fine_tuning.jobs.create(
model=args.model,
training_file=args.training_file,
hyperparameters=hyperparameters,
suffix=args.suffix,
validation_file=args.validation_file,
)
print_model(fine_tuning_job)

@staticmethod
def retrieve(args: CLIFineTuningJobsRetrieveArgs) -> None:
fine_tuning_job: FineTuningJob = get_client().fine_tuning.jobs.retrieve(
Expand Down

0 comments on commit b26a01a

Please sign in to comment.