Skip to content

Commit d2e9015

Browse files
committed
chore: move cache dir option to GlobalOptions
Signed-off-by: Donnie Adams <[email protected]>
1 parent 14735f9 commit d2e9015

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ The GPTScript instance allows the caller to run gptscript files, tools, and othe
2424

2525
When creating a `GTPScript` instance, you can pass the following global options. These options are also available as run `Options`. Anything specified as a run option will take precedence over the global option.
2626

27+
- `CacheDir`: The directory to use for caching. Default (""), which uses the default cache directory.
2728
- `APIKey`: Specify an OpenAI API key for authenticating requests
2829
- `BaseURL`: A base URL for an OpenAI compatible API (the default is `https://api.openai.com/v1`)
2930
- `DefaultModel`: The default model to use for chat completion requests

gptscript_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ func TestRestartFailedRun(t *testing.T) {
414414
Instructions: instructions,
415415
},
416416
}
417-
run, err := g.Evaluate(context.Background(), Options{DisableCache: true, GlobalOptions: GlobalOptions{Env: []string{"EXIT_CODE=1"}}}, tools...)
417+
run, err := g.Evaluate(context.Background(), Options{GlobalOptions: GlobalOptions{Env: []string{"EXIT_CODE=1"}}, DisableCache: true}, tools...)
418418
if err != nil {
419419
t.Fatalf("Error executing tool: %v", err)
420420
}

opts.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ type GlobalOptions struct {
77
OpenAIBaseURL string `json:"BaseURL"`
88
DefaultModel string `json:"DefaultModel"`
99
DefaultModelProvider string `json:"DefaultModelProvider"`
10+
CacheDir string `json:"CacheDir"`
1011
Env []string `json:"env"`
1112
}
1213

@@ -31,6 +32,7 @@ func (g GlobalOptions) toEnv() []string {
3132
func completeGlobalOptions(opts ...GlobalOptions) GlobalOptions {
3233
var result GlobalOptions
3334
for _, opt := range opts {
35+
result.CacheDir = firstSet(opt.CacheDir, result.CacheDir)
3436
result.OpenAIAPIKey = firstSet(opt.OpenAIAPIKey, result.OpenAIAPIKey)
3537
result.OpenAIBaseURL = firstSet(opt.OpenAIBaseURL, result.OpenAIBaseURL)
3638
result.DefaultModel = firstSet(opt.DefaultModel, result.DefaultModel)
@@ -55,10 +57,9 @@ func firstSet[T comparable](in ...T) T {
5557
type Options struct {
5658
GlobalOptions `json:",inline"`
5759

60+
DisableCache bool `json:"disableCache"`
5861
Confirm bool `json:"confirm"`
5962
Input string `json:"input"`
60-
DisableCache bool `json:"disableCache"`
61-
CacheDir string `json:"cacheDir"`
6263
SubTool string `json:"subTool"`
6364
Workspace string `json:"workspace"`
6465
ChatState string `json:"chatState"`

0 commit comments

Comments
 (0)