Skip to content
Open
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
2 changes: 1 addition & 1 deletion cmd/cli/commands/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ func newRunCmd() *cobra.Command {
}
},
RunE: func(cmd *cobra.Command, args []string) error {
model := args[0]
model := normalizeModelIdentifier(args[0])
prompt := ""
argsLen := len(args)
if argsLen > 1 {
Expand Down
23 changes: 23 additions & 0 deletions cmd/cli/commands/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,29 @@
return model
}

// normalizeModelIdentifier expands a user-provided model reference into a fully
// qualified model identifier expected by the engine.
//
// The CLI intentionally strips default values (org and tag) when displaying
// models to improve readability. However, users should be able to pass the same
// shorthand forms back to the CLI (e.g. "mxbai-embed-large").
//
// This function restores the implicit defaults to ensure round-trip consistency
// between `docker model list` output and subsequent CLI commands.
func normalizeModelIdentifier(model string) string {
// If no organization is provided, assume the default org.
if !strings.Contains(model, "/") {
model = defaultOrg + "/" + model
}

// If no tag is provided, assume the default tag.
if lastSlash := strings.LastIndex(model, "/"); !strings.Contains(model[lastSlash+1:], ":") {

Check failure on line 175 in cmd/cli/commands/utils.go

View workflow job for this annotation

GitHub Actions / lint (darwin)

File is not properly formatted (gci)

Check failure on line 175 in cmd/cli/commands/utils.go

View workflow job for this annotation

GitHub Actions / lint (linux)

File is not properly formatted (gci)
model = model + ":" + defaultTag
}

return model
}

// requireExactArgs returns a cobra.PositionalArgs validator that ensures exactly n arguments are provided
func requireExactArgs(n int, cmdName string, usageArgs string) cobra.PositionalArgs {
return func(cmd *cobra.Command, args []string) error {
Expand Down
Loading