This commit is contained in:
Blake Mizerany 2024-05-01 15:56:59 -07:00
parent 844217bcf1
commit 889c5b1a75
2 changed files with 17 additions and 4 deletions

View File

@ -222,6 +222,7 @@ func (nopSeeker) Seek(int64, int) (int64, error) {
} }
func parseNameFill(name, fill string) model.Name { func parseNameFill(name, fill string) model.Name {
fill = cmp.Or(fill, "bllamo.com/library/_:latest")
f := model.ParseNameBare(fill) f := model.ParseNameBare(fill)
if !f.IsFullyQualified() { if !f.IsFullyQualified() {
panic(fmt.Errorf("invalid fill: %q", fill)) panic(fmt.Errorf("invalid fill: %q", fill))

View File

@ -1,6 +1,7 @@
package server package server
import ( import (
"cmp"
"context" "context"
"encoding/json" "encoding/json"
"errors" "errors"
@ -26,6 +27,7 @@ import (
"golang.org/x/exp/slices" "golang.org/x/exp/slices"
"github.com/ollama/ollama/api" "github.com/ollama/ollama/api"
"github.com/ollama/ollama/client/ollama"
"github.com/ollama/ollama/client/registry" "github.com/ollama/ollama/client/registry"
"github.com/ollama/ollama/gpu" "github.com/ollama/ollama/gpu"
"github.com/ollama/ollama/llm" "github.com/ollama/ollama/llm"
@ -35,11 +37,20 @@ import (
"github.com/ollama/ollama/version" "github.com/ollama/ollama/version"
) )
// envs
var (
envRegistryBaseURL = cmp.Or(os.Getenv("OLLAMA_REGISTRY_BASE_URL"), "https://bllamo.com")
)
func init() {
ollama.I_Acknowledge_This_API_Is_Unstable = true
}
var experiments = sync.OnceValue(func() []string { var experiments = sync.OnceValue(func() []string {
return strings.Split(os.Getenv("OLLAMA_EXPERIMENT"), ",") return strings.Split(strings.ToLower(os.Getenv("OLLAMA_EXPERIMENT")), ",")
}) })
func useExperiemntal(flag string) bool { func useExperiment(flag string) bool {
return slices.Contains(experiments(), flag) return slices.Contains(experiments(), flag)
} }
@ -454,9 +465,9 @@ func (s *Server) PullModelHandler(c *gin.Context) {
return return
} }
if useExperiemntal("pull") { if useExperiment("pull") {
rc := &registry.Client{ rc := &registry.Client{
BaseURL: os.Getenv("OLLAMA_REGISTRY_BASE_URL"), BaseURL: envRegistryBaseURL,
} }
modelsDir, err := modelsDir() modelsDir, err := modelsDir()
if err != nil { if err != nil {
@ -464,6 +475,7 @@ func (s *Server) PullModelHandler(c *gin.Context) {
return return
} }
cache := &cache{dir: modelsDir} cache := &cache{dir: modelsDir}
println("DIR: ", modelsDir)
// TODO(bmizerany): progress updates // TODO(bmizerany): progress updates
if err := rc.Pull(c.Request.Context(), cache, model); err != nil { if err := rc.Pull(c.Request.Context(), cache, model); err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()}) c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})