gptscript-ai/gptscript

Provide better output when `sys.find` does not return any files.

Opened this issue · 1 comments

Steps to reproduce the problem:

  1. git clone https://github.com/gptscript-ai/gptscript
  2. Create a new gptscript using sys.find tool will not return any files
 % cat examples/testfind.gpt 
tools: sys.find

Find all sample *.exe file in examples/
  1. Execute this script .
  2. Notice that there is no output in this case
 % gptscript examples/testfind.gpt
17:18:34 started  [main]
17:18:34 sent     [main]
         content  [1] content | Waiting for model response...
         content  [1] content | tool call sys -> {"directory":"examples/","pattern":"*.exe"}
17:18:35 started  [sys.find(2)] [input={"directory":"examples/","pattern":"*.exe"}]
17:18:35 sent     [sys.find(2)]
17:18:35 ended    [sys.find(2)]
17:18:35 continue [main]
17:18:35 sent     [main]
         content  [1] content | Waiting for model response...
17:18:36 continue [main]
2024/02/28 17:18:36 invalid continue call, no completion needed

Tool not providing any output in this case , results in the gptscript using this tool along with other tools.

This behavior can be seen with some non existent files being used when executing samples-readme.gpt script from /examples directory.

17:23:20 started  [main]
17:23:20 sent     [main]
17:23:20 started  [sys.find(2)] [input={"directory":"examples/","pattern":"*.gpt"}]
17:23:20 sent     [sys.find(2)]
17:23:20 ended    [sys.find(2)]
17:23:20 continue [main]
17:23:20 sent     [main]
17:23:20 started  [summary(3)] [input={"file": "examples/sample1.gpt"}]
17:23:20 started  [summary(4)] [input={"file": "examples/sample3.gpt"}]
17:23:20 started  [summary(5)] [input={"file": "examples/sample2.gpt"}]
17:23:20 sent     [summary(3)]
17:23:20 sent     [summary(4)]
17:23:20 sent     [summary(5)]
         content  [4] content | Waiting for model response...
17:23:20 started  [summary(6)->sys.read(6)] [input={"filename":"examples/sample1.gpt"}]
17:23:20 sent     [summary(6)->sys.read(6)]
2024/02/28 17:23:20 open examples/sample1.gpt: no such file or directory

This issue is addressed in the latest version.

We get "No *.exe files were found in the examples/ directory." error as output when sys.tool finds no matching file to return.