How to use GPT-3 in Google Apps Script
GPT-3 (Generative Pre-trained Transformer 3) is a state-of-the-art language generation model developed by OpenAI. It has been trained on a diverse range of internet text and can generate human-like text on a wide range of topics.
Why don't you use GPT-3 in Google Sheets? It's definitely useful if you could make it possible.
I prepared two options to use GPT-3 with Google Sheets. You can follow the tutorial according to your purpose and skill set.
- Clone the sample sheet which has already deployed scripts.
- Create a new sheet and deploy scripts from your local development environment.
Create your account at OpenAI
You need to create an account at the first.
Access to OpenAI API keys, create a new secret key and copy it to your clipboard.
1. Clone the sample sheet which has already deployed scripts
You can clone this sample sheet if you want to use GPT-3 function immediately without deployment.
Note: You need to set the OpenAI API key into script properties even though you cloned the sample sheet.
How to set the OpenAI API key into script properties
- Open your Apps Script project.
- At the left, click Project Settings The icon for project settings.
- To add the first property, under Script Properties click Add script property.
- To add second and subsequent properties, under Script Properties click Edit script properties > Add script property.
- For Property, enter the key name. The key name is must be
- For Value, enter the secret key you generated before.
2. Create a new sheet and deploy scripts from your local development environment
Creating a repository from this template and cloning the repository.
You need to install Deno if you want to deploy and develop in your local environment.
Deno v1.29.4 or higher
Check out how to use and follow the documentaion.
3. GPT-3 function
- Authorize this project's script by execution
GPT3()in your Google Workspace
GPT3(prompt, maxTokens, model, temperature) // Example 1 on Google Sheets =GPT3("Hello, world!") // Example 2 on Google Sheets =GPT3(A1, 200) // Example 3 on Google Sheets =GPT3(A1, 300, "text-babbage-001", 0.5)
- prompt: The prompt to generate completions for, encoded as a string, array of strings, array of tokens, or array of token arrays.
- maxTokens: The maximum number of tokens to generate in the completion.
- model: ID of the model to use.
- temperature: What sampling temperature to use. Higher values means the model will take more risks.
The combination between GPT-3 and Google Sheets is really useful. I hope this article will help you improve your productivity.
Top comments (0)