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

Commit 3d4a5bf

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 <[email protected]>
1 parent 9cb94c8 commit 3d4a5bf

File tree

9 files changed

+24
-3
lines changed

9 files changed

+24
-3
lines changed

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 "ai/" + model
41+
}
42+
43+
return 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
@@ -61,7 +61,7 @@ func newPackagedCmd() *cobra.Command {
6161
return nil
6262
},
6363
RunE: func(cmd *cobra.Command, args []string) error {
64-
opts.tag = args[0]
64+
opts.tag = completion.AddDefaultNamespace(args[0])
6565
if err := packageModel(cmd, opts); err != nil {
6666
cmd.PrintErrln("Failed to package model")
6767
return fmt.Errorf("package model: %w", err)

commands/pull.go

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

3838
func pullModel(cmd *cobra.Command, desktopClient *desktop.Client, model string) error {
39+
model = completion.AddDefaultNamespace(model)
3940
var progress func(string)
4041
if isatty.IsTerminal(os.Stdout.Fd()) {
4142
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
@@ -99,7 +99,7 @@ func newRunCmd() *cobra.Command {
9999
return err
100100
}
101101

102-
model := args[0]
102+
model := completion.AddDefaultNamespace(args[0])
103103
prompt := ""
104104
if len(args) == 1 {
105105
if debug {

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)