gas-gpt-starter
is a starter kit to use GPT-3 and ChatGPT in Google Apps Script.
You can clone this sample sheet if you want to use GPT-3 and ChatGPT function immediately without deployment.
Note: You need to set the OpenAI API key into script properties even though you cloned the sample sheet.
👉 Check out how to add script properties.
- Just deploy this project code without development
- Develop locally with TypeScript, Clasp and Deno
- Bundle your files with esbuild
Creating a repository from this template and cloning the repository.
deno task login
Create a .clasp.json
at the root, and then add these settings.
Open the app script from your spreadsheet and check out your script id on the setting page.
{
"scriptId": "<SCRIPT_ID>",
"rootDir": "./dist"
}
- Create a new secret key from OpenAI API keys.
- Set the API key into script properties in your Apps Script project.
Note: The key name is must be OPENAI_API_KEY
.
📖 How to add script properties
Deploy your code to the existing project.
deno task deploy
- Authorize this project's script by execution
- Use
=CHATGPT()
in your Google Workspace
You can add a system message with the second argument.
CHATGPT(prompt, system)
// Example 1 on Google Sheets
=CHATGPT("Hello, world!")
// Example 2 on Google Sheets
=CHATGPT(A1, "You are a helpful assistant.")
- prompt: The prompt to generate completions.
- system: The system message to format response.
- Authorize this project's script by execution
- Use
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.
Build your project.
deno task build
Build your project files and force writes all local files to script.google.com.
deno task deploy
Open the current directory's clasp project on script.google.com.
deno task open
gpt-3.5-turbo
is supported in this project.
You can use four main models with different levels of power suitable for different tasks.
- text-davinci-003
- text-curie-001
- text-babbage-001
- text-ada-001
MIT