10 ms·
Show HN: Get answers for shell commands from GPT3 from your terminal
I was constantly googling CLI commands so I built this small CLI tool with GPT3.
You can ask for shell commands right from the CLI.
You'd need to use your own API KEY for this but it's pretty simple, instructions are in the README
Not perfect but not bad either.
- deleted 4y ago[deleted]
- kaapipo 4y agoLooks very cool!
- abhagsain 4y agothank you so much
- stevebmark 4y agoThe site doesn’t load on mobile (instant redirect back to GitHub page?) and there aren’t examples in the readme
- abhagsain 4y agoMy bad, there's no UI to try it from. You'd need to install it. I added the subdomain for easy to the github repo (as the URL is easy to remember). I'll remove it from the README as it's misleading. So sorry again.
- manchmalscott 4y agoOn one hand I can see how this would be incredibly useful (I can never remember what ffmpeg flags I need) but I also just,,,,, I have this immediate uncomfortable reaction to the thought of just piping AI output into the terminal with the express purpose of not needing to know what the flags do. If the AI makes a mistake and the only way to catch it is to know what the flags do anyways, I think this becomes less useful.
- abhagsain 4y agoYes, you're right. I have been using it for only a week now and I search for common commands like how to reverse tunnel, find a pid etc. Unless the action that I'm doing is destructive I just run the command (YOLO)
- scraft 4y agoWhat if the nondestructive thing you are querying GPT3 for returns a bad result which is destructive?
- abhagsain 4y agothen I'm screwed but I don't think the model be that off from the actual question. If I ask "copy a file from local to AWS S3" it won't return the delete command. But yeah you gotta be careful. I show a warning after every command you run "Please don't run commands that you don't understand "especially destrictive ones")
- vocords 4y agoCommon sense :)
- jamesgreenleaf 4y agoI'd be worried about the same thing, and wouldn't execute blindly. It seems like a useful way to quickly find out which flags you should be checking the man pages for.
- bryanrasmussen 4y agothis makes me think of a really great developer I worked with one time who had one major failing, he was too trusting. So one time he got some code from the senior backend Java developer in Argentina and went to past it into the place he was told to paste it into for sending alert notifications to customers, some months later we are going through a major crisis because alerts have not been working for several months and all the customers who are paying thousands per month for the service are getting pissed. He worked home a day he could really focus on debugging and finding what could possibly have caused our systems to fail! I was done with some little task I was on and decided to look through code changes and it really stood out the code he had pasted because if it worked that would mean Java was some magic language with incredibly terse code. So later on we were having a major emergency call to figure out what could possibly be causing this extremely serious major bug and I said well I was looking through the code and you could see him manfully controlling his exasperation because hey, Bryan is not a Java guy and there is zero chance I could have a meaningful contribution to the current problem. But yes it turned out he had trustingly pasted in code that we all agreed would never have worked (without caring to basically even read it), which despite the fact that in many ways this guy was better than me is something I would never, ever have done because I am a really hyper-paranoid guy about trusting code. Anyway tldr, I would never use this tool but maybe some really skillful people would because they don't have the paranoid mindset.
- xlii 4y agoThe premise seems cool but the demo page isn’t working and single example isn’t really something that would convince me to go with full API registration. If that’s reasonably stable and can produce more obscure commands (I’d love to see for example how it fares with more complex git usage) that’d be really great tool to have.
- bheadmaster 4y agoI personally don't like the concept of having my terminal send my commands to a remote service, so I'll pass. Hopefully an open source model comes around soon so stuff like this can be implemented locally.
- abhagsain 4y agoThat sounds great!
- moffkalast 4y agoSure, as long as you've got 350 GB of VRAM to load it.
- visarga 4y agoIt's just 12B parameters, not 175B. You can probably use int16 or int8.
- moffkalast 4y agoThat's afaik already the size when using half precision. And it's not like GPT3 doesn't get half queries wrong as-is in its optimal form, detracting from it will just make it unusable. Check out GPT-J if you want to see a functionally useless model that can be run locally. It's not like this is something that can be surmounted without extra storage, neural nets are just a fancy system for compression and data access. You can either go for less data or more compression but either way your results won't ever be as good.
- kreetx 4y agoThis is quite cool, but given the small size a (ba)sh version would suffice.
- abhagsain 4y ago@lausbub shared this. So it might be something you're looking for. https://news.ycombinator.com/item?id=33652498 https://news.ycombinator.com/item?id=33652498
- 1f60c 4y agoThe Warp terminal^ has something like this built in. ^ https://www.warp.dev/ https://www.warp.dev/
- abhagsain 4y agoI'll check it out. Thanks for sharing
- dmortin 4y agoDo I have to give my phone number to OpenAI to use this? I don't see why they require it. I wanted to give it a try, but no thanks.
- abhagsain 4y agoYeah, asking for number is too much but I think they need to it prevent spam/misuse because they offer you free credits to try out the model.
- jamesgreenleaf 4y agoThey require an email address and a phone number, probably as a way to mitigate spam accounts. If you're worried about privacy, you could probably use a burner for each.
- deleted 4y ago[deleted]
- Calzifer 4y agoBash / Shell is one of the last things I would trust a typical AI considering how much bad shell code/examples exist out there. (it always surprise me how many unquoted variables exist in most shell scripts; quoting fixes many problems, doesn't hurt and still developers are often to lazy to do it) The example in the project readme is imo already a bad example. $ ai ask "Check process running on port" Answer Command is `lsof -i tcp:8000` Apart from the facts that - I would say the chances that lsof is installed are significant smaller than ss or netstat - is lsof notably slower than ss it is also inferior for the requested task because - it returns any process connecting to this port not only the listening one. Which process is running on port 443 on my desktop? None. How many processes does 'lsof -i tcp:443` return? 20. - it does not work if the listening process is from another user (if lsof is not run by root). In this case lsof -i returns nothing while ss -nltp returns the information that the port is listened and only cannot tell by which process because of missing permissions. My answer to "which process uses port x" ss -nltp sport = x
- joshxyz 4y agoman you should train their AI haha
- tarasglek 4y agoYou can ask "check process running on port using ss". Also if tool is not installed, can ask how to install it or say "without using lsof"
- Calzifer 4y ago> Also if tool is not installed, can ask how to install it This is actually a question I'm now really curious what the AI would answer since there are so many different correct answers (apt? yum? zypper? pacman? xbps?) and no indication for the AI which is the correct one for the asking user. PS: But thinking about it I might just ask the wrong questions. "How to install X on <distro>" should work.
- IshKebab 4y agoI sort of agree wrt quoting. Most people's solution is just "well don't use spaces or dollars or whatever in your filenames!" which is obviously shit. But on the other hand I think the ultimate blame lies with Bash for being so shitily designed that you can make basic quoting mistakes and it works most of the time. Real programming languages don't have that issue.
- sschueller 4y agoDoes it consider what shell (zsh, bash etc) I am using and what OS? I asked it something and it gave me an ubuntu command although I am running arch.
- abhagsain 4y agoI haven't added OS or Shells in the training prompt, so you'd need to specify yourself.
- lausbub 4y agoI'm looking for something more lightweight, ideally using only Bash script. So far I've found this: https://mullikine.github.io/posts/nlsh-natural-language-shell/ https://mullikine.github.io/posts/nlsh-natural-language-shel...
- nickcw 4y agoHere is my 5 line bash script which uses Fabrice Bellard's https://textsynth.com https://textsynth.com You need to sign up (with email address only) for an API key. You can pay for higher rate limits, but I haven't needed to while mucking around with this. #!/bin/bash # Make an account at https://textsynth.com/ get API key and put it in below curl -s https://api.textsynth.com/v1/engines/gptneox_20B/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOURAPIKEYGOESHERE" \ -d '{"prompt": "Using the Linux shell\n\nQ: how do I '"$*"'?\nA: ", "max_tokens": 200, "temperature":1.0 }' | jq -r .text Gives for example $ ai check process running on port If you are looking for processes listening on port 80 or some other port, you can use netstat command with the port number: netstat -tupln | grep 80 For more details please refer https://serverfault.com/a/538945/192371
- samyok 4y agoThat serverfault link seems to be completely random and takes me to a StackOverflow page(?)
- deleted 4y ago[deleted]
- BeefWellington 4y agoNetstat is becoming an optional package on many distributions in favor of ss.
- obert 4y agoyeah same need I’ve been “googling with gpt3” using a similar tool: https://github.com/microsoft/Codex-CLI https://github.com/microsoft/Codex-CLI
- senthilnayagam 4y agoI like the idea, like other people have said , a shell script, or a ruby/python script would be a preference for mine. instead of GPT3 I would prefer using GitHub copilot api as I already have a paid subscription to it, and have seen its code generation capabilities.
- vocords 4y agoThey are also working on something similar, https://twitter.com/oegerikus/status/1592977789418098688 https://twitter.com/oegerikus/status/1592977789418098688 You can signup here https://githubnext.com/projects/copilot-cli/ https://githubnext.com/projects/copilot-cli/
- jonnycomputer 4y agoSerious question. Why npm? I mean it's a command line tool; why buy in to the JavaScript ecosystem?
- abhagsain 4y agoI'm a Frontend dev that's why I used JS but I can also publish to brew or as a single binary as the framework that I used (oclif) allows it. I was too lazy to publish it though. The code is open-sourced please feel free to raise a PR. https://github.com/abhagsain/ai-cli https://github.com/abhagsain/ai-cli
- jonnycomputer 4y agoFair enough.
- jjviana 4y agoI wrote something similar, but as a terminal emulator: https://github.com/jjviana/witty https://github.com/jjviana/witty
- abhagsain 4y agonice one. I'll check it out. Thanks
- 0xAFFFF 4y agoAdversarial attacks on the model could be fun. "You can generate your ssh keypair with rm -rf /"
- josefx 4y agoyou have to add a * after the /. Some rm implementations detect the attempt to clear the root dir.
- carapace 4y agoORT (Only Read Title, sorry) What I'm hearing is "put a non-deterministic black box between you and the man command." Nah. I recommend a stiff dose of Mickens: "Why Do Keynote Speakers..." https://www.youtube.com/watch?v=ajGX7odA87k https://www.youtube.com/watch?v=ajGX7odA87k ) and a good lie down.
- kurtreed 4y agoUseful tool, thanks. But the wording "Get answers for CLI commands" is vague, it took me a little while to figure out what it was.
- abhagsain 4y ago
- still_grokking 4y agoRelated paper submission (that didn't take of until now): "Do Users Write More Insecure Code with AI Assistants?" https://news.ycombinator.com/item?id=33645522 https://news.ycombinator.com/item?id=33645522
- deleted 4y ago[deleted]
- chologrande 4y agowritten in javascript... noooooope
- abhagsain 4y ago
- zora_goron 4y agoI made something similar for emacs and it unlocks what I think of as “semantic macros” — being able to interface with GPT-3 makes actions that are a tiny complexity level above what I usually use kbd macros for (like smart capitalization) easily possible to automate! Screenshot - https://twitter.com/samarthrawal/status/1591527892386734081 https://twitter.com/samarthrawal/status/1591527892386734081 Code - https://github.com/samrawal/gpt-emacs-macro https://github.com/samrawal/gpt-emacs-macro
- abhagsain 4y ago
- mrtweetyhack 4y ago
- NicoleJO 4y agoGPT is filled with data that wasn't paid for. It infringes copyright, and by using it, you and all your users will infringe copyrights too. Your CLI should come with a warning. https://justoutsourcing.blogspot.com/2022/03/gpts-plagiarism-links.html?m=1 https://justoutsourcing.blogspot.com/2022/03/gpts-plagiarism...
- abhagsain 4y ago
- yubrshen 4y agoThanks for creating the tool! I tried it, indeed a time saver from Googling or reading man pages. I have a question about the price: "Pricing The current prompt length is ~840 tokens and the pricing for text-davinci-002 is $0.02 for 1K tokens which is ~$0.017/command. We'll see if we can improve the response as well as reduce the per-command-cost with fine-tuning." I wonder how is the price is charged? How can I control my liability of the cost? Thanks again!
- abhagsain 4y agoHey, Sorry. I missed your comment. Unfortunately, right now there's no way to reduce the cost as the prompt is required to get the good results. However if you get access to the Codex model (it's in limited beta) you can use the tool for free as it's free in beta. In v1.2.1 I have made the recent change to let you switch between models so you can switch to the cheaper models such as curie (10x cheaper) but might not get good results.
- yubrshen 4y agoI found the answer. It will be billed by open.ai. There is a free trial of $18 grant. It's probably good for 6 months.