Skip to content

Add CLI Tools for Chat Model Fine‑Tuning #50

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions src/openai/cli/_tools/fine_tunes.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
# openai/cli/chat_fine_tunes.py
import click
import json
from openai import FineTunes

@click.group()
def chat_fine_tunes():
"""Manage chat model fine-tuning."""
pass

@chat_fine_tunes.command("create")
@click.option("-f", "--file", required=True, type=click.Path(exists=True), help="Training dataset (JSONL).")
@click.option("-m", "--model", required=True, help="Base chat model (e.g., gpt-4o-mini).")
def create(file, model):
"""Create a new chat fine-tuning job."""
with open(file, "r") as f:
lines = [json.loads(l) for l in f]
for idx, example in enumerate(lines):
if "messages" not in example:
raise click.ClickException(f"Line {idx+1} missing 'messages'.")
resp = FineTunes.create(model=model, training_file=file)
click.echo(f"Created chat fine-tune: {resp['id']}")

from __future__ import annotations

import sys
Expand Down