Browse Source

Merge pull request #3714 from ollama/mxyng/model-name-host

types/model: support : in PartHost for host:port
Michael Yang 1 year ago
parent
commit
52ebe67a98
2 changed files with 6 additions and 0 deletions
  1. 5 0
      types/model/name.go
  2. 1 0
      types/model/name_test.go

+ 5 - 0
types/model/name.go

@@ -521,6 +521,8 @@ func parts(s string) iter_Seq2[PartKind, string] {
 						return
 					}
 					state, j, partLen = PartModel, i, 0
+				case PartHost:
+					// noop: support for host:port
 				default:
 					yield(PartExtraneous, s[i+1:j])
 					return
@@ -678,6 +680,9 @@ func isValidByteFor(kind PartKind, c byte) bool {
 	if kind == PartNamespace && c == '.' {
 		return false
 	}
+	if kind == PartHost && c == ':' {
+		return true
+	}
 	if c == '.' || c == '-' {
 		return true
 	}

+ 1 - 0
types/model/name_test.go

@@ -40,6 +40,7 @@ var testNames = map[string]fields{
 	"user/model":                     {namespace: "user", model: "model"},
 	"example.com/ns/mistral:7b+Q4_0": {host: "example.com", namespace: "ns", model: "mistral", tag: "7b", build: "Q4_0"},
 	"example.com/ns/mistral:7b+X":    {host: "example.com", namespace: "ns", model: "mistral", tag: "7b", build: "X"},
+	"localhost:5000/ns/mistral":      {host: "localhost:5000", namespace: "ns", model: "mistral"},
 
 	// invalid digest
 	"mistral:latest@invalid256-": {},