Compare commits

...

2 Commits

Author SHA1 Message Date
Bruce MacDonald
9051578ecb use os.pathseparator 2024-02-28 10:17:23 -05:00
Bruce MacDonald
17f391c25f expand user home dir in OLLAMA_MODELS 2024-02-26 15:57:51 -05:00

View File

@ -103,13 +103,16 @@ 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
}
if models, exists := os.LookupEnv("OLLAMA_MODELS"); exists {
if strings.HasPrefix(models, "~"+string(os.PathSeparator)) {
return filepath.Join(home, models[2:]), nil
}
return models, nil
}
return filepath.Join(home, ".ollama", "models"), nil
}