Skip to content
This repository was archived by the owner on Aug 14, 2025. It is now read-only.

Commit f3f4515

Browse files
authored
fix: model register missing model-type and not accepting metadata (#11)
# What does this PR do? Added the ability to specify the model type when registering models. Also fixed a bug with passing metadata which would result in the following error: ``` Error Type: BadRequestError │ │ Details: Error code: 400 - {'error': {'detail': {'errors': [{'loc': ['body', 'metadata'], 'msg': 'Input should be a valid dictionary', 'type': 'dict_type'}]}}} ``` Closes: #215 ## Test Plan Run the following commands ``` # Note a Llama Stack Server must be running # Create a venv uv sync --python 3.12 # Install the LSC with the new code changes uv pip install -e . # List the available models llama-stack-client models list # Register the granite-embedding-30m embedding model NOTE must have sentence-transformers as an inference provider llama-stack-client models register granite-embedding-30m --provider-id "sentence-transformers" --provider-model-id ibm-granite/granite-embedding-30m-english --metadata '{"embedding_dimension": 384}' --model-type embedding # Verify the embedding model added are present llama-stack-client models list ```
1 parent 745a94e commit f3f4515

File tree

1 file changed

+15
-1
lines changed
  • src/llama_stack_client/lib/cli/models

1 file changed

+15
-1
lines changed

src/llama_stack_client/lib/cli/models/models.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# This source code is licensed under the terms described in the LICENSE file in
55
# the root directory of this source tree.
66

7+
import json
78
from typing import Optional
89

910
import click
@@ -93,12 +94,23 @@ def get_model(ctx, model_id: str):
9394
console.print(table)
9495

9596

97+
class JSONParamType(click.ParamType):
98+
name = "json"
99+
100+
def convert(self, value, param, ctx):
101+
try:
102+
return json.loads(value)
103+
except json.JSONDecodeError as e:
104+
self.fail(f"Invalid JSON: {e}", param, ctx)
105+
106+
96107
@click.command(name="register", help="Register a new model at distribution endpoint")
97108
@click.help_option("-h", "--help")
98109
@click.argument("model_id")
99110
@click.option("--provider-id", help="Provider ID for the model", default=None)
100111
@click.option("--provider-model-id", help="Provider's model ID", default=None)
101-
@click.option("--metadata", help="JSON metadata for the model", default=None)
112+
@click.option("--metadata", type=JSONParamType(), help="JSON metadata for the model", default=None)
113+
@click.option("--model-type", type=click.Choice(["llm", "embedding"]), default="llm", help="Model type: llm, embedding")
102114
@click.pass_context
103115
@handle_client_errors("register model")
104116
def register_model(
@@ -107,6 +119,7 @@ def register_model(
107119
provider_id: Optional[str],
108120
provider_model_id: Optional[str],
109121
metadata: Optional[str],
122+
model_type: Optional[str],
110123
):
111124
"""Register a new model at distribution endpoint"""
112125
client = ctx.obj["client"]
@@ -117,6 +130,7 @@ def register_model(
117130
provider_id=provider_id,
118131
provider_model_id=provider_model_id,
119132
metadata=metadata,
133+
model_type=model_type,
120134
)
121135
if response:
122136
console.print(f"[green]Successfully registered model {model_id}[/green]")

0 commit comments

Comments
 (0)