Skip to content
This repository was archived by the owner on Oct 6, 2025. It is now read-only.
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
11 changes: 11 additions & 0 deletions commands/completion/functions.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package completion

import (
"strings"

"github.com/docker/model-cli/desktop"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -31,3 +33,12 @@ func ModelNames(desktopClient func() *desktop.Client, limit int) cobra.Completio
return names, cobra.ShellCompDirectiveNoFileComp
}
}

// ensures the model string contains a slash, and if not, prepends "ai/".
func AddDefaultNamespace(model string) string {
if strings.Contains(model, "/") {
return model
}

return "ai/" + model
}
4 changes: 3 additions & 1 deletion commands/inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ func newInspectCmd() *cobra.Command {
"See 'docker model inspect --help' for more information",
)
}

args[0] = completion.AddDefaultNamespace(args[0])
return nil
},
RunE: func(cmd *cobra.Command, args []string) error {
Expand All @@ -47,7 +49,7 @@ func newInspectCmd() *cobra.Command {
}

func inspectModel(args []string, openai bool, remote bool, desktopClient *desktop.Client) (string, error) {
modelName := args[0]
modelName := completion.AddDefaultNamespace(args[0])
if openai {
model, err := desktopClient.InspectOpenAI(modelName)
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions commands/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"fmt"
"os"
"strings"
"time"

"github.com/docker/go-units"
Expand Down Expand Up @@ -127,6 +128,7 @@ func prettyPrintModels(models []dmrm.Model) string {
continue
}
for _, tag := range m.Tags {
tag = strings.TrimPrefix(tag, "ai/")
appendRow(table, tag, m)
}
}
Expand Down
2 changes: 1 addition & 1 deletion commands/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func newPackagedCmd() *cobra.Command {
return nil
},
RunE: func(cmd *cobra.Command, args []string) error {
opts.tag = args[0]
opts.tag = completion.AddDefaultNamespace(args[0])
if err := packageModel(cmd, opts); err != nil {
cmd.PrintErrln("Failed to package model")
return fmt.Errorf("package model: %w", err)
Expand Down
1 change: 1 addition & 0 deletions commands/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ func newPullCmd() *cobra.Command {
}

func pullModel(cmd *cobra.Command, desktopClient *desktop.Client, model string, ignoreRuntimeMemoryCheck bool) error {
model = completion.AddDefaultNamespace(model)
var progress func(string)
if isatty.IsTerminal(os.Stdout.Fd()) {
progress = TUIProgress
Expand Down
1 change: 1 addition & 0 deletions commands/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func newPushCmd() *cobra.Command {
}

func pushModel(cmd *cobra.Command, desktopClient *desktop.Client, model string) error {
model = completion.AddDefaultNamespace(model)
response, progressShown, err := desktopClient.Push(model, TUIProgress)

// Add a newline before any output (success or error) if progress was shown.
Expand Down
2 changes: 2 additions & 0 deletions commands/rm.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ func newRemoveCmd() *cobra.Command {
"See 'docker model rm --help' for more information",
)
}

args[0] = completion.AddDefaultNamespace(args[0])
return nil
},
RunE: func(cmd *cobra.Command, args []string) error {
Expand Down
2 changes: 1 addition & 1 deletion commands/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func newRunCmd() *cobra.Command {
return err
}

model := args[0]
model := completion.AddDefaultNamespace(args[0])
prompt := ""
args_len := len(args)
if args_len > 1 {
Expand Down
2 changes: 2 additions & 0 deletions commands/unload.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ func newUnloadCmd() *cobra.Command {
"See 'docker model unload --help' for more information.",
)
}

args[0] = completion.AddDefaultNamespace(args[0])
return nil
}
c.Flags().BoolVar(&all, "all", false, "Unload all running models")
Expand Down
Loading