diff --git a/.gitignore b/.gitignore index 87797408..bcfc2a3c 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ dist .envrc codegen.log Brewfile.lock.json +.DS_Store diff --git a/src/llama_stack_client/lib/cli/models/models.py b/src/llama_stack_client/lib/cli/models/models.py index a7eb2c44..12734806 100644 --- a/src/llama_stack_client/lib/cli/models/models.py +++ b/src/llama_stack_client/lib/cli/models/models.py @@ -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") diff --git a/src/llama_stack_client/lib/cli/shields/shields.py b/src/llama_stack_client/lib/cli/shields/shields.py index ec12b4ab..3c0999c1 100644 --- a/src/llama_stack_client/lib/cli/shields/shields.py +++ b/src/llama_stack_client/lib/cli/shields/shields.py @@ -29,17 +29,35 @@ 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) @@ -47,7 +65,12 @@ def list(ctx): @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(