A tool plugin for LLM that allows you to execute arbitrary shell commands suggested by the LLM.
This tool can be dangerous, and for this reason, this tool prompts for confirmation before running each command. Review all commands carefully before authorizing.
Install this plugin in the same environment as LLM:
llm install llm-tools-execute-shellTo run a single prompt:
llm --tool execute_shell "What's the current date and time?"To run in chat mode:
$ llm chat --tool execute_shell
...
> My req.py script is broken. Can you run it and fix the error?
...
LLM wants to run command: 'python req.py'
Are you sure you want to run the above command? (y/n): y
Traceback (most recent call last):
File "/tmp/foo/req.py", line 1, in <module>
import requests
ModuleNotFoundError: No module named 'requests'
LLM wants to run command: 'pip install requests'
Are you sure you want to run the above command? (y/n): y
...
LLM wants to run command: 'python req.py'
Are you sure you want to run the above command? (y/n): y
{'origin': 'success'}
It looks like the `req.py` script was failing because the `requests` module was not installed. I've installed it for you, and now the script runs successfully.To set up this plugin locally, first checkout the code. Then create a new virtual environment:
cd llm-tools-execute-shell
python -m venv venv
source venv/bin/activateNow install the dependencies and test dependencies:
python -m pip install -e '.[test]'To run the tests:
python -m pytest