migrate registry domain
This commit is contained in:
parent
09c0972a6a
commit
bf5ba6065b
@ -468,7 +468,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",
|
||||||
|
@ -3,6 +3,8 @@ package server
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io/fs"
|
||||||
|
"log/slog"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@ -21,7 +23,7 @@ type ModelPath struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
DefaultRegistry = "registry.ollama.ai"
|
DefaultRegistry = "ollama.com"
|
||||||
DefaultNamespace = "library"
|
DefaultNamespace = "library"
|
||||||
DefaultTag = "latest"
|
DefaultTag = "latest"
|
||||||
DefaultProtocolScheme = "https"
|
DefaultProtocolScheme = "https"
|
||||||
@ -151,3 +153,33 @@ func GetBlobsPath(digest string) (string, error) {
|
|||||||
|
|
||||||
return path, nil
|
return path, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func migrateRegistryDomain() error {
|
||||||
|
manifests, err := GetManifestPath()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
olddomainpath := filepath.Join(manifests, "registry.ollama.ai")
|
||||||
|
newdomainpath := filepath.Join(manifests, DefaultRegistry)
|
||||||
|
|
||||||
|
return filepath.Walk(olddomainpath, func(path string, info fs.FileInfo, err error) error {
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if !info.IsDir() {
|
||||||
|
slog.Info("migrating registry domain", "path", path)
|
||||||
|
newpath := filepath.Join(newdomainpath, strings.TrimPrefix(path, olddomainpath))
|
||||||
|
if err := os.MkdirAll(filepath.Dir(newpath), 0o755); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := os.Rename(path, newpath); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
}
|
||||||
|
@ -1070,6 +1070,13 @@ func Serve(ln net.Listener) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// migrate registry.ollama.ai to ollama.com
|
||||||
|
if err := migrateRegistryDomain(); err != nil {
|
||||||
|
if !errors.Is(err, os.ErrNotExist) {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ctx, done := context.WithCancel(context.Background())
|
ctx, done := context.WithCancel(context.Background())
|
||||||
schedCtx, schedDone := context.WithCancel(ctx)
|
schedCtx, schedDone := context.WithCancel(ctx)
|
||||||
sched := InitScheduler(schedCtx)
|
sched := InitScheduler(schedCtx)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user