Now Reading
change into a 1000x engineer or die tryin’

change into a 1000x engineer or die tryin’

2023-03-29 07:13:52

header-img

 

For millennia, programmers have searched far and large for the vaunted 10X Engineer. Sadly, on account of inflation — actual and imagined, 10X simply received’t reduce it anymore. We’d like greater positive aspects, greater wins, extra code, extra PRs, extra traces, much less linting, and many others….Subsequently, on this article I’ll cowl how you can catapult your productiveness to the heavens through a collection of command line wrapper features across the OpenAI API.

First off, you’ll want an OpenAI API key. You may get this by going here and signing up.

 

Truthful warning, I don’t use bash — or technically, zsh now for Mac. I exploit Fish — heartbreaking, I do know. Both manner, the gist of it’ll largely stay the identical and it’s a good excercise to implement it your self in bash or zsh.

 

However, let’s get began.

 

Hey GPT

The very first thing we’d like is to get solutions to any and each query we could have.

bash

# mannequin: gpt-4 is in non-public beta (should get from waitlist)
# mannequin: gpt-3.5-turbo (if you do not have entry)

perform hey_gpt -a immediate
    set gpt (curl https://api.openai.com/v1/chat/completions -s 
    -H "Content material-Sort: software/json" 
    -H "Authorization: Bearer $OPENAI_API_KEY" 
    -d '{
        "mannequin": "gpt-4",
        "messages": [{"role": "user", "content": "'$prompt'"}],
        "temperature": 0.7
    }')
    echo $gpt | jq -r '.decisions[0].message.content material'
finish

One different fast word if you’re making an attempt to copy that is that you’ll want jq put in. For those who don’t have it: you should.

I’m not going to dive tremendous deep into the nice tuning of the mannequin parameters — you may learn extra about that here.

What I’ll say although, is that I alias this perform to the letter h in order that I can simply kind the next:

bs

chip

make

 

Good, good…now onto the actual positive aspects.

 

Information GPT

One frequent sample that I’ve noticed myself utilizing is a combination of immediate + information.

bash

perform data_gpt -a immediate information
    set prompt_input (echo "$immediate: $information" | string be a part of ' ')

    curl https://api.openai.com/v1/chat/completions -s 
    -H "Content material-Sort: software/json" 
    -H "Authorization: Bearer $OPENAI_API_KEY" 
    -d '{
        "mannequin": "gpt-4",
        "messages": [{"role": "user", "content": "'$prompt_input'"}],
        "temperature": 0.7
    }' | jq -r '.decisions[0].message.content material'
finish

nba

Link to generated dataset

ans

awk

py

git

Clearly, the use instances listed here are fairly huge. I experimented with one other model that was capable of learn enter that was piped in, however the escaping was messy and it simply appears cleaner to jot down to a file and cat that for now.

See Also

Up to now these examples are pretty much like the expertise you get utilizing ChatGPT. Nevertheless, there are some variations (1.) I discover having it uncovered on the CLI stage makes me extra prone to experiment with GPT (2.) The flexibility to make use of these features inside extra instructions — as an example, it’s nice when mixed with GitHub’s CLI or this Jira CLI (3.) Lastly, you can even chain a number of invocations — giving among the really feel of instruments like LangChain.

 

IMG GPT

One final remaining meme-worthy instance is the Create Image endpoint.

bash

perform img_gpt -a immediate
    set create_img (curl https://api.openai.com/v1/photos/generations -s 
    -H "Content material-Sort: software/json" 
    -H "Authorization: Bearer $OPENAI_API_KEY" 
    -d '{
        "immediate": "'$immediate'",
        "n": 1,
        "dimension": "1024x1024"
    }')
    echo $create_img | jq
    set url (echo $create_img | jq -r '.information[0].url')
    set rand_num (random 1 1000000)
    curl -s $url -o img-"$rand_num".png
finish

ai-img

dog

Generated picture

 

Wacky

One other helpful endpoint is Code Edits. It does, kind of, what’s says. You’ll be able to ask it for revisions on code—improve runtime complexity, re-write as one-liner, add doc string, etc…. Nevertheless, as a substitute of producing a wrapper for it utilizing fish we’ll use what we’ve already written—a fast glimpse into the close to future:

bash

perform openai_edits_api
    h 'are you able to generate a golang script that reads from stdin and sends that to the OpenAI Code Edits API endpoint - embrace solely the code nothing else' | string exchange '```' '' > openai_edits_api.go
    h 'are you able to generate the instructions to construct and run the golang script - solely embrace the instructions' | string exchange '```' '' > openai_edits_api.sh
    data_gpt 'are you able to generate some checks for the next golang script' (cat openai_edits_api.go | string accumulate) | string exchange '```' '' > openai_edits_api_test.go
    data_gpt 'are you able to generate a makefile for a golang mission with the next information' (ls) | string exchange '```' '' > Makefile
finish

It’s a bit wild, however that may successfully get you 90% of the way in which there all through primary sentences with a bit gentle cleanup—wild to say the least.

 

Conclusion

One very last thing to contemplate is that that is actually solely the start. Final week OpenAI introduced Plugins—literal steroids for an already overpowered workhorse. I feel the actual differentiator within the coming months/years will probably be developer productiveness. Good, unhealthy or detached there appears to a be an unavoidable benefit to those that aggressively undertake workflows that lean into AI versus preventing, or ignoring, it. I feel there’s an oncoming paradigm of speedy prototyping mixed with simulation that may assist to isolate and check numerous elements of a mission. Moreover, the power for translating languages and developer productiveness in new languages. The area of what’s doable is getting fuzzier with a robust understanding of the basics. I don’t suppose this replaces programmers, extra so offers fascinating new methods to try to resolve bigger issues in murkier domains.

Hopefully this text opened your thoughts to potential new workflows and potential time optimizations!

Source Link

What's Your Reaction?
Excited
0
Happy
0
In Love
0
Not Sure
0
Silly
0
View Comments (0)

Leave a Reply

Your email address will not be published.

2022 Blinking Robots.
WordPress by Doejo

Scroll To Top