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
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 47 additions and 11 deletions

View file

@ -15,6 +15,7 @@ import (
"github.com/gin-gonic/gin"
"github.com/ollama/ollama/api"
"github.com/ollama/ollama/envconfig"
"github.com/ollama/ollama/llm"
)
@ -86,6 +87,7 @@ func checkFileExists(t *testing.T, p string, expect []string) {
func TestCreateFromBin(t *testing.T) {
p := t.TempDir()
t.Setenv("OLLAMA_MODELS", p)
envconfig.LoadConfig()
var s Server
w := createRequest(t, s.CreateModelHandler, api.CreateRequest{
@ -111,6 +113,7 @@ func TestCreateFromBin(t *testing.T) {
func TestCreateFromModel(t *testing.T) {
p := t.TempDir()
t.Setenv("OLLAMA_MODELS", p)
envconfig.LoadConfig()
var s Server
w := createRequest(t, s.CreateModelHandler, api.CreateRequest{
@ -151,6 +154,7 @@ func TestCreateFromModel(t *testing.T) {
func TestCreateRemovesLayers(t *testing.T) {
p := t.TempDir()
t.Setenv("OLLAMA_MODELS", p)
envconfig.LoadConfig()
var s Server
w := createRequest(t, s.CreateModelHandler, api.CreateRequest{
@ -197,6 +201,7 @@ func TestCreateRemovesLayers(t *testing.T) {
func TestCreateUnsetsSystem(t *testing.T) {
p := t.TempDir()
t.Setenv("OLLAMA_MODELS", p)
envconfig.LoadConfig()
var s Server
w := createRequest(t, s.CreateModelHandler, api.CreateRequest{
@ -252,6 +257,7 @@ func TestCreateUnsetsSystem(t *testing.T) {
func TestCreateMergeParameters(t *testing.T) {
p := t.TempDir()
t.Setenv("OLLAMA_MODELS", p)
envconfig.LoadConfig()
var s Server
w := createRequest(t, s.CreateModelHandler, api.CreateRequest{
@ -354,6 +360,7 @@ func TestCreateMergeParameters(t *testing.T) {
func TestCreateReplacesMessages(t *testing.T) {
p := t.TempDir()
t.Setenv("OLLAMA_MODELS", p)
envconfig.LoadConfig()
var s Server
w := createRequest(t, s.CreateModelHandler, api.CreateRequest{
@ -429,6 +436,7 @@ func TestCreateReplacesMessages(t *testing.T) {
func TestCreateTemplateSystem(t *testing.T) {
p := t.TempDir()
t.Setenv("OLLAMA_MODELS", p)
envconfig.LoadConfig()
var s Server
w := createRequest(t, s.CreateModelHandler, api.CreateRequest{
@ -474,6 +482,7 @@ func TestCreateTemplateSystem(t *testing.T) {
func TestCreateLicenses(t *testing.T) {
p := t.TempDir()
t.Setenv("OLLAMA_MODELS", p)
envconfig.LoadConfig()
var s Server
w := createRequest(t, s.CreateModelHandler, api.CreateRequest{
@ -519,6 +528,7 @@ func TestCreateLicenses(t *testing.T) {
func TestCreateDetectTemplate(t *testing.T) {
p := t.TempDir()
t.Setenv("OLLAMA_MODELS", p)
envconfig.LoadConfig()
var s Server
t.Run("matched", func(t *testing.T) {