Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ dist
.envrc
codegen.log
Brewfile.lock.json
.DS_Store
36 changes: 28 additions & 8 deletions src/llama_stack_client/lib/cli/models/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,42 @@ def list_models(ctx):
console = Console()

headers = [
"model_type",
"identifier",
"provider_id",
"provider_resource_id",
"provider_alias",
"metadata",
"model_type",
"provider_id",
]
response = client.models.list()
if response:
table = Table()
for header in headers:
table.add_column(header)
table = Table(
show_lines=True, # Add lines between rows for better readability
padding=(0, 1), # Add horizontal padding
expand=True, # Allow table to use full width
)

# Configure columns with specific styling
table.add_column("model_type", style="blue")
table.add_column("identifier", style="bold cyan", no_wrap=True, overflow="fold")
table.add_column(
"provider_resource_id", style="yellow", no_wrap=True, overflow="fold"
)
table.add_column("metadata", style="magenta", max_width=30, overflow="fold")
table.add_column("provider_id", style="green", max_width=20)

for item in response:
row = [str(getattr(item, header)) for header in headers]
table.add_row(*row)
table.add_row(
item.model_type,
item.identifier,
item.provider_resource_id,
str(item.metadata or ""),
item.provider_id,
)

# Create a title for the table
console.print("\n[bold]Available Models[/bold]\n")
console.print(table)
console.print(f"\nTotal models: {len(response)}\n")


@click.command(name="get")
Expand Down
39 changes: 31 additions & 8 deletions src/llama_stack_client/lib/cli/shields/shields.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,48 @@ def list(ctx):
console = Console()

shields_list_response = client.shields.list()
headers = []
if shields_list_response and len(shields_list_response) > 0:
headers = sorted(shields_list_response[0].__dict__.keys())
headers = [
"identifier",
"provider_alias",
"params",
"provider_id",
]

if shields_list_response:
table = Table()
for header in headers:
table.add_column(header)
table = Table(
show_lines=True, # Add lines between rows for better readability
padding=(0, 1), # Add horizontal padding
expand=True, # Allow table to use full width
)

table.add_column("identifier", style="bold cyan", no_wrap=True, overflow="fold")
table.add_column(
"provider_alias", style="yellow", no_wrap=True, overflow="fold"
)
table.add_column("params", style="magenta", max_width=30, overflow="fold")
table.add_column("provider_id", style="green", max_width=20)

for item in shields_list_response:
table.add_row(*[str(getattr(item, header)) for header in headers])
table.add_row(
item.identifier,
item.provider_resource_id,
str(item.params or ""),
item.provider_id,
)

console.print(table)


@shields.command()
@click.option("--shield-id", required=True, help="Id of the shield")
@click.option("--provider-id", help="Provider ID for the shield", default=None)
@click.option("--provider-shield-id", help="Provider's shield ID", default=None)
@click.option("--params", type=str, help="JSON configuration parameters for the shield", default=None)
@click.option(
"--params",
type=str,
help="JSON configuration parameters for the shield",
default=None,
)
@click.pass_context
@handle_client_errors("register shield")
def register(
Expand Down