@@ -87,24 +87,46 @@ func asPrinter(cmd *cobra.Command) standalone.StatusPrinter {
8787 return & commandPrinter {cmd : cmd }
8888}
8989
90- // stripDefaultsFromModelName removes the default "ai/" prefix and ":latest" tag for display.
90+ // stripDefaultsFromModelName removes the default "ai/" prefix, default registry, and ":latest" tag for display.
9191// Examples:
9292// - "ai/gemma3:latest" -> "gemma3"
9393// - "ai/gemma3:v1" -> "ai/gemma3:v1"
9494// - "myorg/gemma3:latest" -> "myorg/gemma3"
9595// - "gemma3:latest" -> "gemma3"
96+ // - "index.docker.io/ai/gemma3:latest" -> "gemma3"
97+ // - "docker.io/ai/gemma3:latest" -> "gemma3"
98+ // - "docker.io/myorg/gemma3:latest" -> "myorg/gemma3"
9699// - "hf.co/bartowski/model:latest" -> "hf.co/bartowski/model"
97100func stripDefaultsFromModelName (model string ) string {
98- // Check if model has ai/ prefix without tag (implicitly :latest) - strip just ai/
101+ // First, let's handle the default registry prefixes
102+ defaultRegistries := []string {"index.docker.io/" , "docker.io/" }
103+ for _ , reg := range defaultRegistries {
104+ if strings .HasPrefix (model , reg ) {
105+ // Remove the registry prefix
106+ model = strings .TrimPrefix (model , reg )
107+ break
108+ }
109+ }
110+
111+ // If model has default org prefix (without tag, or with :latest tag), strip the org
112+ // but preserve other tags
99113 if strings .HasPrefix (model , defaultOrg + "/" ) {
100- model = strings .TrimPrefix (model , defaultOrg + "/" )
114+ rest := strings .TrimPrefix (model , defaultOrg + "/" )
115+ // Check if the remaining part has :latest tag
116+ if strings .HasSuffix (rest , ":" + defaultTag ) {
117+ // Strip the :latest tag to get just the name
118+ nameWithoutTag := strings .TrimSuffix (rest , ":" + defaultTag )
119+ return nameWithoutTag
120+ }
121+ // If it doesn't have latest tag, keep the rest intact
122+ return rest
101123 }
102124
103- // Check if model has :latest but no slash (no org specified) - strip :latest
125+ // For models without the default org but with :latest tag, just strip the tag (keep the org part)
104126 if strings .HasSuffix (model , ":" + defaultTag ) {
105127 model = strings .TrimSuffix (model , ":" + defaultTag )
106128 }
107129
108- // For other cases (ai/ with custom tag, custom org with :latest, etc.), keep as- is
130+ // For other cases (custom org with :latest, etc.), return as is
109131 return model
110132}
0 commit comments