From 69b98b90e29eea824759f7b90e2a14ba3c2e245a Mon Sep 17 00:00:00 2001 From: Donnie Adams Date: Wed, 7 Aug 2024 17:03:05 -0400 Subject: [PATCH] feat: add disable cache option to parse Signed-off-by: Donnie Adams --- gptscript.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/gptscript.go b/gptscript.go index 24bc35b..ad932aa 100644 --- a/gptscript.go +++ b/gptscript.go @@ -150,9 +150,18 @@ func (g *GPTScript) Run(ctx context.Context, toolPath string, opts Options) (*Ru }).NextChat(ctx, opts.Input) } +type ParseOptions struct { + DisableCache bool +} + // Parse will parse the given file into an array of Nodes. -func (g *GPTScript) Parse(ctx context.Context, fileName string) ([]Node, error) { - out, err := g.runBasicCommand(ctx, "parse", map[string]any{"file": fileName}) +func (g *GPTScript) Parse(ctx context.Context, fileName string, opts ...ParseOptions) ([]Node, error) { + var disableCache bool + for _, opt := range opts { + disableCache = disableCache || opt.DisableCache + } + + out, err := g.runBasicCommand(ctx, "parse", map[string]any{"file": fileName, "disableCache": disableCache}) if err != nil { return nil, err }