Finally, I accessed the GPT-3 API in Snap!

GPT-3 ACCESS IN SNAP!

GPT-3 is a powerful text-generating AI made by OpenAI.

After a lot of playing around, I finally figured it out. I accessed OpenAI's GPT-3 API through Snap's HTTP library!! With the below blocks, you can generate endless text (as long as you provide an API key [see below], and not endless, it has an endpoint).

Screenshots

Screenshot 2022-01-24 12.53.07
Screenshot 2022-01-24 12.52.48
Screenshot 2022-01-24 12.52.32
Please note these results have been slightly formatted but not completely, perfectly edited, so there are formatting issues, such as all the "\n"s.

For raw data, there is also another block:

Note that I couldn't figure out how to incorporate token length, so the generated strings are relatively random in length as of now. @toontalk figured it out so their (his?) solution will be implemented soon.

Check out the blocks that talk to the API. All information that should be needed is inside the blocks' help menu.

Basically done: GPT-3 chatbot that listens to you speak and responds with text-to-speech! It uses the ECraft2Learn libraries- very grateful for their existence.

[You need a VALID API key! You can get one after signing up for access to GPT-3 at OpenAI's website. To sign up you'll need a phone number and an email.]

Can you make an example in a shared project plz

Done.

Put some data in blocks so we can figure out how it's working

I don't understand.

give us a full working example with some data

or some print screen of the sesult...

Right, sorry. Adding right now.

Thank you.

For the "\n" just split by "\n" and then join the list items with a new line in between.

What's wrong here?

That’s not an API key. You need to go to the OpenAI website (beta.openai.com), sign up for GPT-3, and then enter an API key from your API key page. Google can probably provide a better tutorial than I can.

Ugh. I'm trying to sign up for it but I don't have a phone number and it requires one.

It should only require a Google or Microsoft account. Go to OpenAI.com and click sign up.

It still requires a phone number.

Yep… does require a phone number. Maybe you could sign up for Google Voice, and just put your Google Voice number in the phone # prompt. (If you wanted to and had a Google acct.)

I do have a Google account, but I think Google Voice itself requires another phone number. At least it did when my mom tried to get it so I could talk with one of my friends on an Android tablet.

Hmmm. You're right. I have no other solutions :person_shrugging:

Nice! Here's how to add options like max_tokens:

Clearly one can generalise this to include all the API options.

By the way, until Snap! supports API keys by associating them with the user account I use transient variables to hold the API key. That way I won't accidently save a project with the key embedded.

That's a good idea.

That, though, confused me. Why would you have the max_tokens key/value not equal the token length input as well?

I was just providing an example of how to include the options documented here: OpenAI API