From 0cfab527c077aa7eb5b6e2468440e00a3e59ce68 Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Tue, 9 Apr 2024 09:19:46 -0700 Subject: [PATCH] change: switch --cache to --disable-cache --- pkg/cache/cache.go | 11 ++++------- pkg/openai/client.go | 2 +- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/pkg/cache/cache.go b/pkg/cache/cache.go index f86a7f82..bb2941f3 100644 --- a/pkg/cache/cache.go +++ b/pkg/cache/cache.go @@ -18,17 +18,14 @@ type Client struct { } type Options struct { - Cache *bool `usage:"Disable caching" default:"true"` - CacheDir string `usage:"Directory to store cache (default: $XDG_CACHE_HOME/gptscript)"` + DisableCache bool `usage:"Disable caching of LLM API responses"` + CacheDir string `usage:"Directory to store cache (default: $XDG_CACHE_HOME/gptscript)"` } func Complete(opts ...Options) (result Options) { for _, opt := range opts { result.CacheDir = types.FirstSet(opt.CacheDir, result.CacheDir) - result.Cache = types.FirstSet(opt.Cache, result.Cache) - } - if result.Cache == nil { - result.Cache = &[]bool{true}[0] + result.DisableCache = types.FirstSet(opt.DisableCache, result.DisableCache) } if result.CacheDir == "" { result.CacheDir = filepath.Join(xdg.CacheHome, version.ProgramName) @@ -54,7 +51,7 @@ func New(opts ...Options) (*Client, error) { } return &Client{ dir: opt.CacheDir, - noop: !*opt.Cache, + noop: opt.DisableCache, }, nil } diff --git a/pkg/openai/client.go b/pkg/openai/client.go index 6988ee0a..ee86bd23 100644 --- a/pkg/openai/client.go +++ b/pkg/openai/client.go @@ -68,7 +68,7 @@ func complete(opts ...Options) (result Options, err error) { if result.Cache == nil { result.Cache, err = cache.New(cache.Options{ - Cache: new(bool), + DisableCache: true, }) }