Skip to content

Kazuki-tam/gas-gpt-starter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gas-gpt-starter

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.

Status

Release (latest by date) Issues Maintenance Release date

Features

  • Just deploy this project code without development
  • Develop locally with TypeScript, Clasp and Deno
  • Bundle your files with esbuild

Main dependencies

Prerequisites

🦕 How to install Deno

How to use

Creating a repository from this template and cloning the repository.

Login google account

deno task login

Connect to your existing project

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"
}

Set OpenAI API key into script properties

  1. Create a new secret key from OpenAI API keys.
  2. Set the API key into script properties in your Apps Script project.

Note: The key name is must be OPENAI_API_KEY.

Script Properties

📖 How to add script properties

Upload a script project

Deploy your code to the existing project.

deno task deploy

CHATGPT function

  1. Authorize this project's script by execution
  2. 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.")

CHATGPT Parameters

  1. prompt: The prompt to generate completions.
  2. system: The system message to format response.

GPT-3 function

  1. Authorize this project's script by execution
  2. 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)

GPT3 function on Google Sheets

GPT-3 Parameters

  1. prompt: The prompt to generate completions for, encoded as a string, array of strings, array of tokens, or array of token arrays.
  2. maxTokens: The maximum number of tokens to generate in the completion.
  3. model: ID of the model to use.
  4. temperature: What sampling temperature to use. Higher values means the model will take more risks.

📖 Learn more parameters

Available Commands

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

ChatGPT

gpt-3.5-turbo is supported in this project.

GPT-3

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

📖 Learn more API reference

License

MIT