add OLLAMA_MODELS to envconfig (#5029)

This commit is contained in:
Patrick Devine
2024-06-13 15:52:03 -04:00
committed by GitHub
parent 1fd236d177
commit 94618b2365
8 changed files with 47 additions and 11 deletions

View File

@@ -8,6 +8,8 @@ import (
"path/filepath"
"regexp"
"strings"
"github.com/ollama/ollama/envconfig"
)
type ModelPath struct {
@@ -104,14 +106,7 @@ func (mp ModelPath) GetShortTagname() string {
// modelsDir returns the value of the OLLAMA_MODELS environment variable or the user's home directory if OLLAMA_MODELS is not set.
// The models directory is where Ollama stores its model files and manifests.
func modelsDir() (string, error) {
if models, exists := os.LookupEnv("OLLAMA_MODELS"); exists {
return models, nil
}
home, err := os.UserHomeDir()
if err != nil {
return "", err
}
return filepath.Join(home, ".ollama", "models"), nil
return envconfig.ModelsDir, nil
}
// GetManifestPath returns the path to the manifest file for the given model path, it is up to the caller to create the directory if it does not exist.