From 10da41d6779bab00e83abdedc3da66096ef418a4 Mon Sep 17 00:00:00 2001 From: K0IN <19688162+K0IN@users.noreply.github.com> Date: Fri, 22 Dec 2023 23:16:20 +0100 Subject: [PATCH] Add Cache flag to api (#1642) --- api/types.go | 2 ++ docs/api.md | 3 ++- llm/ext_server.go | 3 ++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/api/types.go b/api/types.go index 43f642c3..7662599a 100644 --- a/api/types.go +++ b/api/types.go @@ -103,6 +103,7 @@ type Options struct { MirostatEta float32 `json:"mirostat_eta,omitempty"` PenalizeNewline bool `json:"penalize_newline,omitempty"` Stop []string `json:"stop,omitempty"` + Cache bool `json:"cache,omitempty"` } // Runner options which must be set when the model is loaded into memory @@ -355,6 +356,7 @@ func DefaultOptions() Options { MirostatEta: 0.1, PenalizeNewline: true, Seed: -1, + Cache: true, Runner: Runner{ // options set when the model is loaded diff --git a/docs/api.md b/docs/api.md index aa176d4c..51b65425 100644 --- a/docs/api.md +++ b/docs/api.md @@ -306,7 +306,8 @@ curl http://localhost:11434/api/generate -d '{ "embedding_only": false, "rope_frequency_base": 1.1, "rope_frequency_scale": 0.8, - "num_thread": 8 + "num_thread": 8, + "cache": true } }' ``` diff --git a/llm/ext_server.go b/llm/ext_server.go index 0d3327da..5a760e3e 100644 --- a/llm/ext_server.go +++ b/llm/ext_server.go @@ -234,7 +234,8 @@ func predict(llm extServer, opts api.Options, ctx context.Context, predict Predi "penalize_nl": opts.PenalizeNewline, "seed": opts.Seed, "stop": opts.Stop, - "image_data": imageData, + "image_data": imageData, + "cache_prompt": opts.Cache, } if predict.Format == "json" {