It's like Alexa/Siri/Cortana for your terminal!
This is a basic Python shell (really, it's a fancy wrapper over the system shell) that takes a task and asks OpenAI for what Linux bash command to run based on your description. For safety reasons, you can look at the command and cancel before actually running it.
To be clear, I'm not trying to convince you that having an AI model figure out what Linux command to run based on your written description is a good idea, but the commands that it generates are, well - watch the video if you want to see.
There are several pre-canned ways of interacting with the models that OpenAI provides (the "GPT" models): completing a provided fragment, answering a question, generating "ideas" from a topic, summarizing a passage, etc.
This shell uses the question-and-answer format and provides the model with an "example context" and examples of input and output. The example context I used is simply, "Linux bash command to accomplish the task". I currently provide 5 examples with each request which is more than the recommended 2 or 3 examples, and is partly why the cost of each query is high.
The real magic of GPT is that you can provide it just a couple sentences about what you want and it can follow the format quite well.
It can generate commands for basic Unix tools, ImageMagick, etc. It can give ffmpeg a good attempt, but it often tries mapping a dozen or more tracks and hits the token limit before it's done generating output.
I tried asking it to "generate an image of three giraffes", but it just created a blank 300x300 image.
One of my original ideas was to do an entire data-science preprocessing routine using the AI shell. It failed to download country GDP or population data that I requested, and also failed on commands like "sort data.csv by the last column descending". So that idea got scrapped.
In some ways, OpenAI's models are like a weird version of Google - it can give you results based on a huge breadth of Web content it's seen, but it can also just make stuff up.
One example not shown in the video:
~> download IE5dom.exe
<~ wget http://download.microsoft.com/download/3/4/1/3419d6e5-d0e4-4fde-b0e5-5b6a9c4d8e2d/IE5DOM.EXE
That seems like a valid download link, but it 404s and I'm pretty sure the GUID is made-up. At least, Google showed no results for it and it suspiciously has a bunch of alternating numbers and letters. (IE5dom.exe is the IE5 High-Encryption Pack.)
Another example not shown in the video:
~> telnet into the NSA mainframe
<~ telnet nsa.gov
Which, I guess, seems as good a guess as any other.
OpenAI's review process and pricing model mean that I can't let everyone try this out using my API key, but it should be relatively straightforward to do the same thing with a locally run GPT-2 model. (And, in fact, the code was written with the help of a GPT-2 based AI autocompletion.)
Linux.org.ru (Русский): https://www.linux.org.ru/news/opensource/16276883
You will need an OpenAI API key to use this, or I guess you could hook it up to a local GPT model. Also, it's a bad idea to use this anyways, since it could come up with some bad commands.
New in v0.0.3: Fixed readline wrapping calculation. Added --reverse flag that gives natural-language description of the command you typed in. Actually use bash.
Note: There's some weirdness going on with readline and wrapping that I'm not sure how to fix. You can try commenting out "import readline" to not use readline. (Fixed in v0.0.3)
I promised I would take suggestions from viewers on what else to try running in the shell, and here it is:
An OpenAI-powered shell wrapper that tries to Do What You Mean.
⚠️ DO NOT USE THIS SHELL IF YOU DO NOT WANT DATA LOSS OR OTHER NEGATIVE CONSEQUENCES INCLUDING BUT NOT LIMITED TO ACTUALLY EMAILING JEFF BEZOS ⚠️
You will need to install the Python dependencies listed in either Pipfile (for Pipenv users) or requirements.txt (for pip users).
You will also need a valid OpenAI API key and the budget for whatever charges this shell may rack up. Set the environment variable OPENAI_API_KEY to your API key.
Aish is similar to a typical CLI shell, but instead of typing in the name of a process to run, you type in what you want to accomplish. It will then query the OpenAI API for a bash command to run.
You have a chance to approve the generated command by pressing Enter, or canceling and not running the command with ^C.
Commands may not do the right thing, or may do something harmful or otherwise unwanted.
--live-dangerously: if run with this flag, aish will not ask for approval before running the AI-generated command. DO NOT USE THIS FLAG.
--reverse: Generate natural-language descriptions of the shell command that you type in.