diff --git a/cmd/cli/commands/run.go b/cmd/cli/commands/run.go index 2f18aaee..d25dd287 100644 --- a/cmd/cli/commands/run.go +++ b/cmd/cli/commands/run.go @@ -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 { diff --git a/cmd/cli/commands/utils.go b/cmd/cli/commands/utils.go index c77f472b..1f9f3654 100644 --- a/cmd/cli/commands/utils.go +++ b/cmd/cli/commands/utils.go @@ -156,6 +156,29 @@ func stripDefaultsFromModelName(model string) string { 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:], ":") { + 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 {