rebase main
This commit is contained in:
parent
bf5ba6065b
commit
8d62a65ca7
@ -606,7 +606,7 @@ curl http://localhost:11434/api/chat -d '{
|
|||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"model": "registry.ollama.ai/library/llama3:latest",
|
"model": "ollama.com/library/llama3:latest",
|
||||||
"created_at": "2023-12-12T14:13:43.416799Z",
|
"created_at": "2023-12-12T14:13:43.416799Z",
|
||||||
"message": {
|
"message": {
|
||||||
"role": "assistant",
|
"role": "assistant",
|
||||||
|
@ -1046,14 +1046,6 @@ func Serve(ln net.Listener) error {
|
|||||||
|
|
||||||
slog.SetDefault(slog.New(handler))
|
slog.SetDefault(slog.New(handler))
|
||||||
|
|
||||||
blobsDir, err := GetBlobsPath("")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if err := fixBlobs(blobsDir); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if !envconfig.NoPrune {
|
if !envconfig.NoPrune {
|
||||||
// clean up unused layers and manifests
|
// clean up unused layers and manifests
|
||||||
if err := PruneLayers(); err != nil {
|
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
|
// migrate registry.ollama.ai to ollama.com
|
||||||
if err := migrateRegistryDomain(); err != nil {
|
if err := migrateRegistryDomain(); err != nil {
|
||||||
if !errors.Is(err, os.ErrNotExist) {
|
if !errors.Is(err, os.ErrNotExist) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// END MIGRATION
|
||||||
|
|
||||||
ctx, done := context.WithCancel(context.Background())
|
ctx, done := context.WithCancel(context.Background())
|
||||||
schedCtx, schedDone := context.WithCancel(ctx)
|
schedCtx, schedDone := context.WithCancel(ctx)
|
||||||
|
@ -35,7 +35,7 @@ func Unqualified(n Name) error {
|
|||||||
const MissingPart = "!MISSING!"
|
const MissingPart = "!MISSING!"
|
||||||
|
|
||||||
const (
|
const (
|
||||||
defaultHost = "registry.ollama.ai"
|
defaultHost = "ollama.com"
|
||||||
defaultNamespace = "library"
|
defaultNamespace = "library"
|
||||||
defaultTag = "latest"
|
defaultTag = "latest"
|
||||||
)
|
)
|
||||||
@ -43,7 +43,7 @@ const (
|
|||||||
// DefaultName returns a name with the default values for the host, namespace,
|
// DefaultName returns a name with the default values for the host, namespace,
|
||||||
// and tag parts. The model and digest parts are empty.
|
// 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 namespace is ("library")
|
||||||
// - The default tag is ("latest")
|
// - The default tag is ("latest")
|
||||||
func DefaultName() Name {
|
func DefaultName() Name {
|
||||||
|
@ -20,14 +20,14 @@ func TestParseNameParts(t *testing.T) {
|
|||||||
wantValidDigest bool
|
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{
|
want: Name{
|
||||||
Host: "registry.ollama.ai",
|
Host: "ollama.com",
|
||||||
Namespace: "library",
|
Namespace: "library",
|
||||||
Model: "dolphin-mistral",
|
Model: "dolphin-mistral",
|
||||||
Tag: "7b-v2.6-dpo-laser-q6_K",
|
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",
|
in: "scheme://host:port/namespace/model:tag",
|
||||||
@ -83,14 +83,14 @@ func TestParseNameParts(t *testing.T) {
|
|||||||
Namespace: "namespace",
|
Namespace: "namespace",
|
||||||
Model: "model",
|
Model: "model",
|
||||||
},
|
},
|
||||||
wantFilepath: filepath.Join("registry.ollama.ai", "namespace", "model", "latest"),
|
wantFilepath: filepath.Join("ollama.com", "namespace", "model", "latest"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
in: "model",
|
in: "model",
|
||||||
want: Name{
|
want: Name{
|
||||||
Model: "model",
|
Model: "model",
|
||||||
},
|
},
|
||||||
wantFilepath: filepath.Join("registry.ollama.ai", "library", "model", "latest"),
|
wantFilepath: filepath.Join("ollama.com", "library", "model", "latest"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
in: "h/nn/mm:t",
|
in: "h/nn/mm:t",
|
||||||
@ -193,7 +193,7 @@ func TestNameparseNameDefault(t *testing.T) {
|
|||||||
const name = "xx"
|
const name = "xx"
|
||||||
n := ParseName(name)
|
n := ParseName(name)
|
||||||
got := n.String()
|
got := n.String()
|
||||||
want := "registry.ollama.ai/library/xx:latest"
|
want := "ollama.com/library/xx:latest"
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("parseName(%q).String() = %q; want %q", name, got, want)
|
t.Errorf("parseName(%q).String() = %q; want %q", name, got, want)
|
||||||
}
|
}
|
||||||
@ -290,9 +290,9 @@ func TestParseNameFromFilepath(t *testing.T) {
|
|||||||
|
|
||||||
func TestDisplayShortest(t *testing.T) {
|
func TestDisplayShortest(t *testing.T) {
|
||||||
cases := map[string]string{
|
cases := map[string]string{
|
||||||
"registry.ollama.ai/library/model:latest": "model:latest",
|
"ollama.com/library/model:latest": "model:latest",
|
||||||
"registry.ollama.ai/library/model:tag": "model:tag",
|
"ollama.com/library/model:tag": "model:tag",
|
||||||
"registry.ollama.ai/namespace/model:tag": "namespace/model:tag",
|
"ollama.com/namespace/model:tag": "namespace/model:tag",
|
||||||
"host/namespace/model:tag": "host/namespace/model:tag",
|
"host/namespace/model:tag": "host/namespace/model:tag",
|
||||||
"host/library/model:tag": "host/library/model:tag",
|
"host/library/model:tag": "host/library/model:tag",
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user