Compare commits

..

2 Commits

Author SHA1 Message Date
Blake Mizerany
91613e5951 stop checking for name existence in pull handler (for now) 2024-11-13 23:27:32 -08:00
Blake Mizerany
d1b033c168 server: update checkNameExists to use case-insensitive name comparison
This allows pulls, pushes, and other model operations to be performed
with mixed-case names, which the Ollama registry supports.
2024-11-13 23:08:21 -08:00
3 changed files with 10 additions and 8 deletions

View File

@ -800,9 +800,9 @@ func ShowHandler(cmd *cobra.Command, args []string) error {
case "parameters":
fmt.Println(resp.Parameters)
case "system":
fmt.Print(resp.System)
fmt.Println(resp.System)
case "template":
fmt.Print(resp.Template)
fmt.Println(resp.Template)
}
return nil

View File

@ -540,11 +540,6 @@ func (s *Server) PullHandler(c *gin.Context) {
return
}
if err := checkNameExists(name); err != nil {
c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"error": err.Error()})
return
}
ch := make(chan any)
go func() {
defer close(ch)
@ -628,7 +623,7 @@ func checkNameExists(name model.Name) error {
}
for n := range names {
if strings.EqualFold(n.Filepath(), name.Filepath()) && n != name {
if strings.EqualFold(n.Filepath(), name.Filepath()) && n.EqualFold(name) {
return errors.New("a model with that name already exists")
}
}

View File

@ -298,6 +298,13 @@ func (n Name) LogValue() slog.Value {
return slog.StringValue(n.String())
}
func (n Name) EqualFold(o Name) bool {
return strings.EqualFold(n.Host, o.Host) &&
strings.EqualFold(n.Namespace, o.Namespace) &&
strings.EqualFold(n.Model, o.Model) &&
strings.EqualFold(n.Tag, o.Tag)
}
func isValidLen(kind partKind, s string) bool {
switch kind {
case kindHost: