open-interpreter
open-interpreter copied to clipboard
Linux SHELL flexibility
There are multiple shell programs in Linux, including bash, ash, csh & fish to name a few. They all behave differently and have different syntax. The generated shell script may run on one shell but not another. The shell to target should be selectable using SHELL (as it is currently) and explicit in the system message, or the shell should just always be the same one, e.g. bash.
If the shell can be chosen (e.g. using SHELL defaulting to 'bash'), then the value should be in the execution environment and included in the info of get_info_for_system_message() so that the LLM can target the right shell. When executing the generated code using 'run_code()', the correct shell is determined from the execution environment.
Also, note that shells may differ in how they format content they write to the terminal and how they buffer content of stdin and stdout (or not), and affect the magic related to 'ACTIVE_LINE:' and 'END_OF_EXECUTION'. In particular, currently shell seems to be broken when SHELL is fish.
Create a vedv image with https://github.com/yunielrc/vedv
This fixes it for now when running under fish. It'll probably also work for other non-compatible shells.
SHELL=(which bash) interpreter -y
You could make an alias that does this for you using
alias --save int="SHELL=(which bash) interpreter"
This still leaves the LLM-side of the problem unsolved.
Currently the function schema given to the OpenAI allows the language param to be one of ["python", "shell", "applescript", "javascript", "html"]. Notice the generic "shell". The LLM should have no reason to assume bash or any other particular shell when "shell" is specified, so the resulting script may not work for the local selected shell.
I think the right thing to do is to be explicit about the shell in the function schema or prompt sent to the LLM, so instead of simply "shell", open-interpreter specifies to the LLM "bash", "fish", "tcsh" etc. Of course, if the shell is relatively unknown to the LLM, the resulting answer may still be low-quality.
This fixes it for now when running under fish. It'll probably also work for other non-compatible shells.
SHELL=(which bash) interpreter -yYou could make an alias that does this for you using
alias --save int="SHELL=(which bash) interpreter"
This solution does not seem to work for me. I have a Mac and fish shell. After executing the code it does not return to the interpreter and I have to press CTRL+C every time.
Actually it seems that in bash the problem is that a return line is needed after the question is presented to the user with: "Would you like to run this code? (y/n)".
Is this still a problem with the current version?
Closing this stale issue. Please create a new issue if shell is still an issue. Thanks!