-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from meta-llama/registry
[SDK] adapt to server updates #201
- Loading branch information
Showing
139 changed files
with
6,794 additions
and
2,147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# 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. | ||
from tabulate import tabulate | ||
|
||
def print_table_from_response(response, headers=[]): | ||
if not headers: | ||
headers = sorted(response[0].__dict__.keys()) | ||
|
||
rows = [] | ||
for spec in response: | ||
rows.append( | ||
[ | ||
spec.__dict__[headers[i]] for i in range(len(headers)) | ||
] | ||
) | ||
|
||
print(tabulate(rows, headers=headers, tablefmt="grid")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# 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 | ||
import os | ||
|
||
import yaml | ||
from tabulate import tabulate | ||
|
||
from llama_stack_client import LlamaStackClient | ||
from llama_stack_client.lib.cli.subcommand import Subcommand | ||
from llama_stack_client.lib.cli.configure import get_config | ||
|
||
|
||
class ProvidersParser(Subcommand): | ||
"""Configure Llama Stack Client CLI""" | ||
|
||
def __init__(self, subparsers: argparse._SubParsersAction): | ||
super().__init__() | ||
self.parser = subparsers.add_parser( | ||
"providers", | ||
prog="llama-stack-client providers", | ||
description="List available providers Llama Stack Client CLI", | ||
formatter_class=argparse.RawTextHelpFormatter, | ||
) | ||
self._add_arguments() | ||
self.parser.set_defaults(func=self._run_providers_cmd) | ||
|
||
def _add_arguments(self): | ||
self.endpoint = get_config().get("endpoint") | ||
self.parser.add_argument( | ||
"--endpoint", | ||
type=str, | ||
help="Llama Stack distribution endpoint", | ||
default=self.endpoint, | ||
) | ||
|
||
def _run_providers_cmd(self, args: argparse.Namespace): | ||
client = LlamaStackClient( | ||
base_url=args.endpoint, | ||
) | ||
|
||
headers = [ | ||
"API", | ||
"Provider ID", | ||
"Provider Type", | ||
] | ||
|
||
providers_response = client.providers.list() | ||
rows = [] | ||
|
||
for k, v in providers_response.items(): | ||
for provider_info in v: | ||
rows.append( | ||
[ | ||
k, | ||
provider_info.provider_id, | ||
provider_info.provider_type | ||
] | ||
) | ||
|
||
print(tabulate(rows, headers=headers, tablefmt="grid")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.