forked from phoenix-oss/llama-stack-mirror
llama-models should have extremely minimal cruft. Its sole purpose should be didactic -- show the simplest implementation of the llama models and document the prompt formats, etc. This PR is the complement to https://github.com/meta-llama/llama-models/pull/279 ## Test Plan Ensure all `llama` CLI `model` sub-commands work: ```bash llama model list llama model download --model-id ... llama model prompt-format -m ... ``` Ran tests: ```bash cd tests/client-sdk LLAMA_STACK_CONFIG=fireworks pytest -s -v inference/ LLAMA_STACK_CONFIG=fireworks pytest -s -v vector_io/ LLAMA_STACK_CONFIG=fireworks pytest -s -v agents/ ``` Create a fresh venv `uv venv && source .venv/bin/activate` and run `llama stack build --template fireworks --image-type venv` followed by `llama stack run together --image-type venv` <-- the server runs Also checked that the OpenAPI generator can run and there is no change in the generated files as a result. ```bash cd docs/openapi_generator sh run_openapi_generator.sh ```
61 lines
1.8 KiB
Python
61 lines
1.8 KiB
Python
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
# All rights reserved.
|
|
#
|
|
# This source code is licensed under the terms described in the LICENSE file in
|
|
# the root directory of this source tree.
|
|
|
|
import argparse
|
|
|
|
from llama_stack.cli.subcommand import Subcommand
|
|
from llama_stack.cli.table import print_table
|
|
from llama_stack.models.llama.sku_list import all_registered_models
|
|
|
|
|
|
class ModelList(Subcommand):
|
|
"""List available llama models"""
|
|
|
|
def __init__(self, subparsers: argparse._SubParsersAction):
|
|
super().__init__()
|
|
self.parser = subparsers.add_parser(
|
|
"list",
|
|
prog="llama model list",
|
|
description="Show available llama models",
|
|
formatter_class=argparse.RawTextHelpFormatter,
|
|
)
|
|
self._add_arguments()
|
|
self.parser.set_defaults(func=self._run_model_list_cmd)
|
|
|
|
def _add_arguments(self):
|
|
self.parser.add_argument(
|
|
"--show-all",
|
|
action="store_true",
|
|
help="Show all models (not just defaults)",
|
|
)
|
|
|
|
def _run_model_list_cmd(self, args: argparse.Namespace) -> None:
|
|
from .safety_models import prompt_guard_model_sku
|
|
|
|
headers = [
|
|
"Model Descriptor",
|
|
"Model ID",
|
|
"Context Length",
|
|
]
|
|
|
|
rows = []
|
|
for model in all_registered_models() + [prompt_guard_model_sku()]:
|
|
if not args.show_all and not model.is_featured:
|
|
continue
|
|
|
|
descriptor = model.descriptor()
|
|
rows.append(
|
|
[
|
|
descriptor,
|
|
model.huggingface_repo,
|
|
f"{model.max_seq_length // 1024}K",
|
|
]
|
|
)
|
|
print_table(
|
|
rows,
|
|
headers,
|
|
separate_rows=True,
|
|
)
|