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

Commit 715141d

Browse files
committed
Make "ai/" the default namespace
So we can run commands like: docker model run gpt-oss without the "ai/". This would be similar to ollama where the "library/" is typically not specified. Signed-off-by: Eric Curtin <ecurtin@redhat.com>
1 parent 8886eed commit 715141d

9 files changed

Lines changed: 24 additions & 3 deletions

File tree

commands/completion/functions.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package completion
22

33
import (
4+
"strings"
5+
46
"github.com/docker/model-cli/desktop"
57
"github.com/spf13/cobra"
68
)
@@ -31,3 +33,12 @@ func ModelNames(desktopClient func() *desktop.Client, limit int) cobra.Completio
3133
return names, cobra.ShellCompDirectiveNoFileComp
3234
}
3335
}
36+
37+
// ensures the model string contains a slash, and if not, prepends "ai/".
38+
func AddDefaultNamespace(model string) string {
39+
if strings.Contains(model, "/") {
40+
return model
41+
}
42+
43+
return "ai/" + model
44+
}

commands/inspect.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ func newInspectCmd() *cobra.Command {
2323
"See 'docker model inspect --help' for more information",
2424
)
2525
}
26+
27+
args[0] = completion.AddDefaultNamespace(args[0])
2628
return nil
2729
},
2830
RunE: func(cmd *cobra.Command, args []string) error {
@@ -47,7 +49,7 @@ func newInspectCmd() *cobra.Command {
4749
}
4850

4951
func inspectModel(args []string, openai bool, remote bool, desktopClient *desktop.Client) (string, error) {
50-
modelName := args[0]
52+
modelName := completion.AddDefaultNamespace(args[0])
5153
if openai {
5254
model, err := desktopClient.InspectOpenAI(modelName)
5355
if err != nil {

commands/list.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"bytes"
55
"fmt"
66
"os"
7+
"strings"
78
"time"
89

910
"github.com/docker/go-units"
@@ -127,6 +128,7 @@ func prettyPrintModels(models []dmrm.Model) string {
127128
continue
128129
}
129130
for _, tag := range m.Tags {
131+
tag = strings.TrimPrefix(tag, "ai/")
130132
appendRow(table, tag, m)
131133
}
132134
}

commands/package.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func newPackagedCmd() *cobra.Command {
6363
return nil
6464
},
6565
RunE: func(cmd *cobra.Command, args []string) error {
66-
opts.tag = args[0]
66+
opts.tag = completion.AddDefaultNamespace(args[0])
6767
if err := packageModel(cmd, opts); err != nil {
6868
cmd.PrintErrln("Failed to package model")
6969
return fmt.Errorf("package model: %w", err)

commands/pull.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ func newPullCmd() *cobra.Command {
4141
}
4242

4343
func pullModel(cmd *cobra.Command, desktopClient *desktop.Client, model string, ignoreRuntimeMemoryCheck bool) error {
44+
model = completion.AddDefaultNamespace(model)
4445
var progress func(string)
4546
if isatty.IsTerminal(os.Stdout.Fd()) {
4647
progress = TUIProgress

commands/push.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ func newPushCmd() *cobra.Command {
3434
}
3535

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

3940
// Add a newline before any output (success or error) if progress was shown.

commands/rm.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ func newRemoveCmd() *cobra.Command {
2121
"See 'docker model rm --help' for more information",
2222
)
2323
}
24+
25+
args[0] = completion.AddDefaultNamespace(args[0])
2426
return nil
2527
},
2628
RunE: func(cmd *cobra.Command, args []string) error {

commands/run.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ func newRunCmd() *cobra.Command {
101101
return err
102102
}
103103

104-
model := args[0]
104+
model := completion.AddDefaultNamespace(args[0])
105105
prompt := ""
106106
args_len := len(args)
107107
if args_len > 1 {

commands/unload.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ func newUnloadCmd() *cobra.Command {
5454
"See 'docker model unload --help' for more information.",
5555
)
5656
}
57+
58+
args[0] = completion.AddDefaultNamespace(args[0])
5759
return nil
5860
}
5961
c.Flags().BoolVar(&all, "all", false, "Unload all running models")

0 commit comments

Comments
 (0)