Elffuss BraidHub

kikocis/llama-stack public

bb9be718c121 · 1.4 KiBRawPermalink
1# Copyright (c) Meta Platforms, Inc. and affiliates.
2# All rights reserved.
3#
4# This source code is licensed under the terms described in the LICENSE file in
5# the root directory of this source tree.
6
7import argparse
8
9from llama_stack.cli.subcommand import Subcommand
10
11
12class StackListApis(Subcommand):
13 def __init__(self, subparsers: argparse._SubParsersAction):
14 super().__init__()
15 self.parser = subparsers.add_parser(
16 "list-apis",
17 prog="llama stack list-apis",
18 description="List APIs part of the Llama Stack implementation",
19 formatter_class=argparse.RawTextHelpFormatter,
20 )
21 self._add_arguments()
22 self.parser.set_defaults(func=self._run_apis_list_cmd)
23
24 def _add_arguments(self):
25 pass
26
27 def _run_apis_list_cmd(self, args: argparse.Namespace) -> None:
28 from llama_stack.cli.table import print_table
29 from llama_stack.distribution.distribution import stack_apis
30
31 # eventually, this should query a registry at llama.meta.com/llamastack/distributions
32 headers = [
33 "API",
34 ]
35
36 rows = []
37 for api in stack_apis():
38 rows.append(
39 [
40 api.value,
41 ]
42 )
43 print_table(
44 rows,
45 headers,
46 separate_rows=True,
47 )