From 8d62a65ca7c6eebc0295c2165965fbc61ab4a7da Mon Sep 17 00:00:00 2001 From: Michael Yang Date: Mon, 13 May 2024 12:44:58 -0700 Subject: [PATCH] rebase main --- docs/api.md | 2 +- server/routes.go | 19 +++++++++++-------- types/model/name.go | 4 ++-- types/model/name_test.go | 22 +++++++++++----------- 4 files changed, 25 insertions(+), 22 deletions(-) diff --git a/docs/api.md b/docs/api.md index 816496729..bffa5b23a 100644 --- a/docs/api.md +++ b/docs/api.md @@ -606,7 +606,7 @@ curl http://localhost:11434/api/chat -d '{ ```json { - "model": "registry.ollama.ai/library/llama3:latest", + "model": "ollama.com/library/llama3:latest", "created_at": "2023-12-12T14:13:43.416799Z", "message": { "role": "assistant", diff --git a/server/routes.go b/server/routes.go index 00db0f4b4..cada60f8b 100644 --- a/server/routes.go +++ b/server/routes.go @@ -1046,14 +1046,6 @@ func Serve(ln net.Listener) error { slog.SetDefault(slog.New(handler)) - blobsDir, err := GetBlobsPath("") - if err != nil { - return err - } - if err := fixBlobs(blobsDir); err != nil { - return err - } - if !envconfig.NoPrune { // clean up unused layers and manifests if err := PruneLayers(); err != nil { @@ -1070,12 +1062,23 @@ func Serve(ln net.Listener) error { } } + // MIGRATION + blobsDir, err := GetBlobsPath("") + if err != nil { + return err + } + + if err := fixBlobs(blobsDir); err != nil { + return err + } + // migrate registry.ollama.ai to ollama.com if err := migrateRegistryDomain(); err != nil { if !errors.Is(err, os.ErrNotExist) { return err } } + // END MIGRATION ctx, done := context.WithCancel(context.Background()) schedCtx, schedDone := context.WithCancel(ctx) diff --git a/types/model/name.go b/types/model/name.go index 5e475687e..ee83860b5 100644 --- a/types/model/name.go +++ b/types/model/name.go @@ -35,7 +35,7 @@ func Unqualified(n Name) error { const MissingPart = "!MISSING!" const ( - defaultHost = "registry.ollama.ai" + defaultHost = "ollama.com" defaultNamespace = "library" defaultTag = "latest" ) @@ -43,7 +43,7 @@ const ( // DefaultName returns a name with the default values for the host, namespace, // and tag parts. The model and digest parts are empty. // -// - The default host is ("registry.ollama.ai") +// - The default host is ("ollama.com") // - The default namespace is ("library") // - The default tag is ("latest") func DefaultName() Name { diff --git a/types/model/name_test.go b/types/model/name_test.go index 794d14d79..84ecb6f80 100644 --- a/types/model/name_test.go +++ b/types/model/name_test.go @@ -20,14 +20,14 @@ func TestParseNameParts(t *testing.T) { wantValidDigest bool }{ { - in: "registry.ollama.ai/library/dolphin-mistral:7b-v2.6-dpo-laser-q6_K", + in: "ollama.com/library/dolphin-mistral:7b-v2.6-dpo-laser-q6_K", want: Name{ - Host: "registry.ollama.ai", + Host: "ollama.com", Namespace: "library", Model: "dolphin-mistral", Tag: "7b-v2.6-dpo-laser-q6_K", }, - wantFilepath: filepath.Join("registry.ollama.ai", "library", "dolphin-mistral", "7b-v2.6-dpo-laser-q6_K"), + wantFilepath: filepath.Join("ollama.com", "library", "dolphin-mistral", "7b-v2.6-dpo-laser-q6_K"), }, { in: "scheme://host:port/namespace/model:tag", @@ -83,14 +83,14 @@ func TestParseNameParts(t *testing.T) { Namespace: "namespace", Model: "model", }, - wantFilepath: filepath.Join("registry.ollama.ai", "namespace", "model", "latest"), + wantFilepath: filepath.Join("ollama.com", "namespace", "model", "latest"), }, { in: "model", want: Name{ Model: "model", }, - wantFilepath: filepath.Join("registry.ollama.ai", "library", "model", "latest"), + wantFilepath: filepath.Join("ollama.com", "library", "model", "latest"), }, { in: "h/nn/mm:t", @@ -193,7 +193,7 @@ func TestNameparseNameDefault(t *testing.T) { const name = "xx" n := ParseName(name) got := n.String() - want := "registry.ollama.ai/library/xx:latest" + want := "ollama.com/library/xx:latest" if got != want { t.Errorf("parseName(%q).String() = %q; want %q", name, got, want) } @@ -290,11 +290,11 @@ func TestParseNameFromFilepath(t *testing.T) { func TestDisplayShortest(t *testing.T) { cases := map[string]string{ - "registry.ollama.ai/library/model:latest": "model:latest", - "registry.ollama.ai/library/model:tag": "model:tag", - "registry.ollama.ai/namespace/model:tag": "namespace/model:tag", - "host/namespace/model:tag": "host/namespace/model:tag", - "host/library/model:tag": "host/library/model:tag", + "ollama.com/library/model:latest": "model:latest", + "ollama.com/library/model:tag": "model:tag", + "ollama.com/namespace/model:tag": "namespace/model:tag", + "host/namespace/model:tag": "host/namespace/model:tag", + "host/library/model:tag": "host/library/model:tag", } for in, want := range cases {