Skip to content

Commit

Permalink
llm models --async option
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw committed Nov 13, 2024
1 parent 6684715 commit 5279921
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/help.md
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ Usage: llm models list [OPTIONS]
Options:
--options Show options for each model, if available
--async List async models
--help Show this message and exit.
```

Expand Down
9 changes: 7 additions & 2 deletions llm/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -1015,14 +1015,19 @@ def models():
@click.option(
"--options", is_flag=True, help="Show options for each model, if available"
)
def models_list(options):
@click.option("async_", "--async", is_flag=True, help="List async models")
def models_list(options, async_):
"List available models"
models_that_have_shown_options = set()
for model_with_aliases in get_models_with_aliases():
if async_ and not model_with_aliases.async_model:
continue
extra = ""
if model_with_aliases.aliases:
extra = " (aliases: {})".format(", ".join(model_with_aliases.aliases))
model = model_with_aliases.model
model = (
model_with_aliases.model if not async_ else model_with_aliases.async_model
)
output = str(model) + extra
if options and model.Options.schema()["properties"]:
output += "\n Options:"
Expand Down
8 changes: 8 additions & 0 deletions tests/test_llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,14 @@ def test_llm_models_options(user_path):
result = runner.invoke(cli, ["models", "--options"], catch_exceptions=False)
assert result.exit_code == 0
assert EXPECTED_OPTIONS.strip() in result.output
assert "AsyncMockModel: mock" not in result.output


def test_llm_models_async(user_path):
runner = CliRunner()
result = runner.invoke(cli, ["models", "--async"], catch_exceptions=False)
assert result.exit_code == 0
assert "AsyncMockModel: mock" in result.output


def test_llm_user_dir(tmpdir, monkeypatch):
Expand Down

0 comments on commit 5279921

Please sign in to comment.