gorilla-llm / gorilla-cli

LLMs for your CLI
https://gorilla.cs.berkeley.edu/
Apache License 2.0
1.22k stars 73 forks source link

Cancelling execution with Ctrl-C displays error #44

Closed philipmat closed 9 months ago

philipmat commented 9 months ago

Begin a gorilla command and instead of selecting one of the options, hit Ctrl-C. => an stack trace is displayed on screen:

❯ gorilla list subdirectories recursively
🦍  Welcome to Gorilla. Use arrows to select                                                                                                 

Cancelled by user

Traceback (most recent call last):
  File "/Users/philip/Projects/gorilla-cli/.venv/bin/gorilla", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/Users/philip/Projects/gorilla-cli/.venv/lib/python3.11/site-packages/go_cli.py", line 159, in main
    exit_condition = execute_command(selected_command)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/philip/Projects/gorilla-cli/.venv/lib/python3.11/site-packages/go_cli.py", line 123, in execute_command
    process = subprocess.run(cmd, shell=True, stderr=subprocess.PIPE)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/philip/.pyenv/versions/3.11.4/lib/python3.11/subprocess.py", line 548, in run
    with Popen(*popenargs, **kwargs) as process:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/philip/.pyenv/versions/3.11.4/lib/python3.11/subprocess.py", line 1026, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/Users/philip/.pyenv/versions/3.11.4/lib/python3.11/subprocess.py", line 1808, in _execute_child
    args = list(args)
           ^^^^^^^^^^
TypeError: 'NoneType' object is not iterable

I realize "Do nothing" would be the preferred exit method. Ctrl-C would be faster.

The fix is as simple as adding, before exit_condition = execute_command(selected_command) in go_cli.py a if not selected_command: return

ShishirPatil commented 9 months ago

45 closes this. Thanks @philipmat