Skip to content
Merged
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
6 changes: 6 additions & 0 deletions pkg/distribution/distribution/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,12 @@ func (c *Client) normalizeModelName(model string) string {
return model
}

// Normalize HuggingFace short URL (hf.co) to canonical form (huggingface.co)
// This ensures that hf.co/org/model and huggingface.co/org/model are treated as the same model
if rest, found := strings.CutPrefix(model, "hf.co/"); found {
model = "huggingface.co/" + rest
}

// If it looks like an ID or digest, try to resolve it to full ID
if c.looksLikeID(model) || c.looksLikeDigest(model) {
if fullID := c.resolveID(model); fullID != "" {
Expand Down
22 changes: 22 additions & 0 deletions pkg/distribution/distribution/normalize_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,28 @@ func TestNormalizeModelName(t *testing.T) {
input: "MyModel",
expected: "ai/mymodel:latest",
},

// HuggingFace URL normalization
{
name: "hf.co normalized to huggingface.co",
input: "hf.co/org/model",
expected: "huggingface.co/org/model:latest",
},
{
name: "hf.co with tag normalized to huggingface.co",
input: "hf.co/org/model:Q4_K_M",
expected: "huggingface.co/org/model:Q4_K_M",
},
{
name: "huggingface.co stays unchanged",
input: "huggingface.co/org/model",
expected: "huggingface.co/org/model:latest",
},
{
name: "huggingface.co with tag stays unchanged",
input: "huggingface.co/org/model:Q4_K_M",
expected: "huggingface.co/org/model:Q4_K_M",
},
}

for _, tt := range tests {
Expand Down