forked from phoenix-oss/llama-stack-mirror
Fixes to the llama stack configure
script + inference adapters
This commit is contained in:
parent
4869f2b983
commit
1380d78c19
11 changed files with 124 additions and 37 deletions
60
llama_toolchain/cli/stack/list_providers.py
Normal file
60
llama_toolchain/cli/stack/list_providers.py
Normal file
|
@ -0,0 +1,60 @@
|
|||
# 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_toolchain.cli.subcommand import Subcommand
|
||||
|
||||
|
||||
class StackListProviders(Subcommand):
|
||||
def __init__(self, subparsers: argparse._SubParsersAction):
|
||||
super().__init__()
|
||||
self.parser = subparsers.add_parser(
|
||||
"list-providers",
|
||||
prog="llama stack list-providers",
|
||||
description="Show available Llama Stack Providers for an API",
|
||||
formatter_class=argparse.RawTextHelpFormatter,
|
||||
)
|
||||
self._add_arguments()
|
||||
self.parser.set_defaults(func=self._run_providers_list_cmd)
|
||||
|
||||
def _add_arguments(self):
|
||||
from llama_toolchain.core.distribution import stack_apis
|
||||
|
||||
api_values = [a.value for a in stack_apis()]
|
||||
self.parser.add_argument(
|
||||
"api",
|
||||
type=str,
|
||||
choices=api_values,
|
||||
help="API to list providers for (one of: {})".format(api_values),
|
||||
)
|
||||
|
||||
def _run_providers_list_cmd(self, args: argparse.Namespace) -> None:
|
||||
from llama_toolchain.cli.table import print_table
|
||||
from llama_toolchain.core.distribution import Api, api_providers
|
||||
|
||||
all_providers = api_providers()
|
||||
providers_for_api = all_providers[Api(args.api)]
|
||||
|
||||
# eventually, this should query a registry at llama.meta.com/llamastack/distributions
|
||||
headers = [
|
||||
"Provider ID",
|
||||
"PIP Package Dependencies",
|
||||
]
|
||||
|
||||
rows = []
|
||||
for spec in providers_for_api.values():
|
||||
rows.append(
|
||||
[
|
||||
spec.provider_id,
|
||||
",".join(spec.pip_packages),
|
||||
]
|
||||
)
|
||||
print_table(
|
||||
rows,
|
||||
headers,
|
||||
separate_rows=True,
|
||||
)
|
Loading…
Add table
Add a link
Reference in a new issue