Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Call GPT-3 from Terminal (github.com/ther1d)
156 points by raydiatian on Feb 12, 2023 | hide | past | favorite | 39 comments


Wow this is really cool. There is a trick with ChatGPT where you can get it to simulate a linux terminal[0]. I'm not sure if that would work with GPT3 but probably?

Seems like you could either use this directly or extend the idea to having your real terminal as well as your simulated terminal (keeping in mind with the ChatGPT version you can ask it to add functionality like docker, nix, Kubernetes, python, go, etc) and then pipe things between them.

Even without taking it wherever that goes this still seems pretty handy.

Edit: Thinking more about this, a cool ui would be either "containers", "VMs", or some other fake abstraction you could spin up and ssh / rsync into. Imagining simulated VMs. Would be pretty useful to be able to shell out to that at will to play around with. Perhaps with the ability to prompt OS and installed programs.

[0] https://www.engraved.blog/building-a-virtual-machine-inside/


My favorite demo with ChatGPT is not to ask it to emulate a terminal, but tell it is connected to an Ubuntu 20.04 system by SSH and then ask it to do thing like setup a web server with a blog, secure the server, etc.


Does ChatGPT then spends all day on HN arguing it has to wait for the program to finish compiling?


Looks cool, good work. I made something similar a few months ago, but yours looks a lot more polished.

https://github.com/trentearl/aicli. https://earlearlearl.com/posts/aibash-openai-command-line

I think the next step is to make a platform to create domain specific prompts. For example if you need to use aws cli frequently, write a prompt that has the api types embedded and outputs aws cli filtered through jq. I'm on something like this, hopefully it will benefit this space.


Not mine, just the first one I could find that IsActuallyFunctional™.


I found this one pretty good:

https://github.com/jayhack/llm.sh


Hm, are there similar projects that simply works as a shell filter? Prompt on std in / answer on stdout ?

Would make for a perfect vim companion - select text, hit "!gpt3" - get answer in buffer?

I'm not very keen on running some random shell commands directly - but having them pop into my editor (safe and recommended wrapper for strict shell script - or - sample python cli utility etc).

Ed: As a bonus it would also compose easily - making adding an interface like https://github.com/jayhack/llm.sh on top would be trivial...

Ed2: i see there's https://github.com/jackMort/ChatGPT.nvim and https://github.com/gakonst/rubberduck-gpt3.vim - both of which would be better if they also/just worked as filters.


I use my own similar tool (https://github com/runvnc/askleo) like this in vim

    :r ! askleo a JavaScript function to reverse a string


Thanks! Does it take prompt on stdin too?

Fixed link:

https://github.com/runvnc/askleo


Hmm. I think just command args.


Yes, I had a quick look at the code (nice and simple!). Should be possible to adjust to stdin as well - maybe I'll have a try if I find the time.


Might be able to use xargs


I will try this out this evening.

I want to test how well it generates config files for well-documented software packages like i3wm. Give it some natural language instructions for hot keys and default window behavior and let it go wild. Maybe generate some theming for polybar/rofi & resources based off what I actually want the output to look like.


I was experimenting with the Warp terminal for the first time last week. It includes a similar feature. I was pretty impressed with how well it worked.

[0] https://docs.warp.dev/features/entry/ai-command-search#


MacOS only. Just pointing out to save other non-Apple readers time.


I saw that too! Warp is doing a great job of aggregating features. Hope they release a Linux build sooner than later.


As safe as downloading and runing random sh from internet.

Love it (great project and one step to future), but would not do any of it on my or clients machines/servers.

*From the example, how do you know one of those ffmpeg switches will not wipe your disc ?


You don’t. But thankfully such abuses seem rare.


Not here to argue or prove anything, but to increase awareness.

https://github.com/s0md3v/Diggy/issues/11 ..... ... .

As another point to discussion, hope GPT-3 will not hallucinate obfuscated rm -rf into output.

Still love this and the tools in other comments


I wonder how long the GPT-3 API will be open for general use. Once big money is involved, it's questionable whether it will remain available.


Not long. Sam Altman has basically said it's extremely expensive to run the queries and they need people to pay for it.


GPT3 is paid for. ChatGPT is a fine tuned version (or more modified now) with free access.


The compute to run it is emphatically not free.


Yes, but GPT3 is a paid for product already with no free access (I think they give you some credits when signing up but that's it). This project does not use ChatGPT. ChatGPT is what has free access at the moment.


I just signed up for ChatGPT Plus at $20/month. They have a new "Turbo" model which seems very similar to the normal one. They also said that a ChatGPT API is coming.

I use the OpenAI text-davinci-003 for the service I am building which is somewhat like ChatGPT.


Scroll down to the ffmpeg example. I’m curious to try sgpt “check my changes into Git under a new branch named testing”!


Or sgpt “grep for all files containing the string XYZ either in all caps or mixed case, followed by two digits”. Endlessly promising - may eventually lead to the deprecation of man pages.


> may eventually lead to the deprecation of man pages.

Which is where, among other things, GPT gets its training data from.


I think everything that came after man pages lead to the deprecation of man pages. info, Usenet, forums, Google, Stack Overflow..anything but man pages.


I prefer using copilot.vim and then setting EDITOR to nvim and then using C-x C-e.

Like this https://twitter.com/arjie/status/1575201117595926530?s=46&t=...


HTTPError: 429 Client Error: Too Many Requests for url: https://api.openai.com/v1/completions

first request got this, why?


% sgpt "What is the Arch Linux wiki url"

The official Arch Linux wiki url is https://wiki.archlinux.org/


I'd rather use ChatGPT to help me find a reliable command, that I understand. Then create a shell script for it for future use.

This is a cool trick that is far from a best practice.


That's a fantastic demo


this is the best thing my brain has been teased with in so long. thank you for the video

glad i retired haha elon can hire teenagers now


Has been done before. I don't know what's new about this to make the HN frontpage.


I'm glad it did. I hadn't seen the other ones.


It seems like we need a constant stream of ChatGPT posts. I guess hopefully all the fans will be right and it will replace all knowledge so none of us will even need or be able to afford a computer to be able to use it. :)


“Times, they are a-changin”

Sorry to disappoint, I too am frustrated about ChatGPT/GPT-3/LLM mainstream gossip deluge, but that doesn’t mean I disagree with augmenting my productivity with the latest tools.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: