Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

$ cat ~/.config/openai/completions.json ~/.local/bin/completions { "model": "text-davinci-003", "max_tokens": 1024 } #!/bin/sh jq --rawfile prompt /dev/stdin '.prompt = $prompt' \ ${XDG_CONFIG_HOME:-$HOME/.config}/openai/completions.json | curl --silent https://api.openai.com/v1/completions \ --header "Authorization: Bearer $OPENAI_API_KEY" \ --header "Content-Type: application/json" --data-binary @- | jq -r '.choices[].text'


Well why use jq? you could decompose that into standard unix commands as well :)

The main itch I wanted to scratch for my own exploration with chatgpt was that I found myself doing a lot of curl requests, and then after a few iterations I would come up with one that worked well. The next step was to reproduce that last result (without ideally hitting the openai servers again) and I wanted to pipe it to the next part of my chain.

This project kind of grew out of that. Every time I had more than 2 pipes I created a new "ease of life" parameter.

Although it is possible (and likely) that your working memory is far greater than mine to come up with a command like that.


Sorry, I was not trying to belittle your effort, not at all. In fact, its sort of the other way around. You inspired me enough today (basically because I had to deep-dive and try to debug a problem which turned out to be an openai python bug) to realize how simple it actually is to use the completions API. Also, recently upgraded to Debian Bookworm, I was greeted by the new future that pip install refuses to do what it used to do, forcing you to create a venv. So I learnt about pipx, and realized this is getting a bit out of hand, esp. because the bug I was tracing ended up being somewhere deep in the dependencies of the tool you wrote. Remembering KISS, I went back to shell.

I am sure I could encode stuff with plain other tools as well, but jq is actually handy for escaping json strings. And since it can read variable content from stdin, I was a happy man. Even with decently working emacs integration now.

But again, thanks for writing this. I have both now, and will happily steal ideas from chatblade!


No offense taken at all :) these are some interesting times we live in with the power chatgpt gives us.

The dream is ultimately to leverage chatgpt as a fuzzy text assistant to 10x productivity and I think combining the unix CLI which is optimized for text is the best way to do so.

It is also one of the great powers of the unix CLI that there are many roads that lead to rome.


In Emacs: C-u M-| completions RET




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

Search: