From 491a9930f7331cbf50cdb83cfa02bf170f1a529c Mon Sep 17 00:00:00 2001 From: Simon Edwards Date: Sat, 24 Feb 2024 17:19:23 +0100 Subject: [PATCH] Tell Ollama to not unload models automatically --- backend/internal/engine/ollama/engine_ollama.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/backend/internal/engine/ollama/engine_ollama.go b/backend/internal/engine/ollama/engine_ollama.go index 9ebe7f8..416f2b7 100644 --- a/backend/internal/engine/ollama/engine_ollama.go +++ b/backend/internal/engine/ollama/engine_ollama.go @@ -40,9 +40,10 @@ type chatMessage struct { } type chatPayload struct { - Model string `json:"model"` - Messages []chatMessage `json:"messages"` - Options optionsPayload `json:"options"` + Model string `json:"model"` + Messages []chatMessage `json:"messages"` + Options optionsPayload `json:"options"` + KeepAlive int `json:"keep_alive"` } type chatResponse struct { @@ -74,7 +75,8 @@ func (this *OllamaEngineBackend) Process(work *types.Request, model *data.Model, log.Printf("OllamaEngineBackend Process(): Temperature: %f, TopP: %f\n", preset.Temperature, preset.TopP) previousMessages := work.Messages[0 : len(work.Messages)-1] payload := &chatPayload{ - Model: model.InternalModelID, + Model: model.InternalModelID, + KeepAlive: -1, Messages: slices.Map(previousMessages, func(m data.Message) chatMessage { mRole := "user" if m.Role == role.Assistant {