- Abi Raja
- Follow me on Twitter @_abi_
Excel is a much better playground for GPT3 than the official OpenAI playground. Excel is ubiquitous, incredibly flexible and has a low barrier to entry. I created a custom function for Google Sheets,
AI() that takes a prompt and returns the GPT3 completion. The result is natural language programming for all your tasks, big and small, in your Google Sheets. We'll see how powerful this is through some demos.
Here's a basic example of the function in action:
I haven't published the custom functions,
CATEGORIZE on the Google Marketplace yet but you can get it working in a few easy steps that'll take under 5 minutes. Here's how:
- Create a new Google Sheets custom function. In your Google Sheets toolbar, go to Extensions > App Script. In the editor that opens up, remove the existing boilerplate and copy/paste this code.
- Generate an API key from OpenAI. Sign up for OpenAI if you haven't. Grab your API key by going to the dropdown on the top right, selecting "View API Keys" and creating a new key. Copy this key.
- Update the script with your API key and authorize it. Back in the Apps Script editor, add the OpenAI secret key at the top, replacing the text
"ENTER YOUR SECRET KEY HERE". Save the file and run it. When you run it for the first time, Google will prompt you for permissions to run the script on your account. Feel free to look through the code. It's not doing anything sketchy and is calling the OpenAI API directly.
Now, everything should be ready and all set to go. You can use
CATEGORIZE in that Google Sheet. See the usage addendum below for more tips.
Now for some cool demos.
I recently worked with a fashion startup. As part of an app relaunch, they came up with a new category hierarchy for their items and had to recategorize tens of thousands of items by hand. In the first demo, let’s look at how the
AI custom function makes that trivial.
I like to do my budgeting by hand in Sheets (don’t trust Mint et al with my data). Let’s see how we can use
CATEGORIZE to automate the classification into various budget buckets and save time.
My inspiration for building these functions was this demo I saw on Twitter. Check out the video for demos.
This weekend I built =GPT3(), a way to run GPT-3 prompts in Google Sheets.
It's incredible how tasks that are hard or impossible to do w/ regular formulas become trivial.
For example: sanitize data, write thank you cards, summarize product reviews, categorize feedback... pic.twitter.com/4fXOTpn2vz
— Shubhro Saha (@shubroski) October 31, 2022
We're very close to having a "plain English programming language" for most simple tasks. Want to convert MOV to MP4? Just ask the AI in plain English. You'll get
ffmpeg -i input.mov -c:v libx264 -c:a copy output.mp4 Want to TitleCase a list of names? Just use
AI() in Sheets and get your results in seconds. No more remembering commands, pulling up old notes, using Google and no more context switching. Just a simple tool that translates your thoughts into results.
Of course, right now, you still have to massage the prompt a little bit to get what you want. And a big drawback is that the responses can be slow sometimes. But it's going to get better and faster no doubt.
We’re going to see an explosions of apps that combine GPT3, Stable Diffusion, DALL-E, etc. to save time and money on hundreds of everyday tasks. The models are there. We just have to build the products.
If you enjoyed this, follow me on Twitter for more cool AI demos and products.
- If you get rate limited or run out of credits and see errors in your cells, you’ll need to setup a paid account on OpenAI.
- In Google Sheets, use "&" to concatenate text with cell contents.
- For the
AIfunction, the first argument is the prompt. Play with the prompt until you get the output you’re looking for. If you want a single sentence answer, specify something to that effect ("Respond in a single sentence"). If you want a number only answer, say "Respond with only numbers".
- The second argument (optional) to the
AIfunction is the temperature. Basically, a temperature of 1 will encourage creativity. If you want ad copy, 1 is a good value. But if you want to extract the zip code from a list of addresses, you’d want to set the temperature to 0. Read more here.