Skip to content
Merged
Changes from 2 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
28 changes: 28 additions & 0 deletions unsloth_cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,45 @@
# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0

import typer
from importlib.metadata import version as package_version, PackageNotFoundError

from unsloth_cli.commands.train import train
from unsloth_cli.commands.inference import inference
from unsloth_cli.commands.export import export, list_checkpoints
from unsloth_cli.commands.studio import run as studio_run, studio_app

try:
_version = package_version("unsloth")
except PackageNotFoundError:
_version = "unknown"


def _version_callback(value: bool):
if value:
typer.echo(f"unsloth {_version}")
Comment thread
melroy89 marked this conversation as resolved.
Outdated
raise typer.Exit()


app = typer.Typer(
help = "Command-line interface for Unsloth training, inference, and export.",
context_settings = {"help_option_names": ["-h", "--help"]},
)


@app.callback()
def _main(
version: bool = typer.Option(
None,
"--version",
Comment thread
melroy89 marked this conversation as resolved.
"-V",
callback = _version_callback,
is_eager = True,
help = "Show version and exit.",
),
):
pass


app.command()(train)
app.command()(inference)
app.command()(export)
Expand Down