GPT-3 and Google Sheets (2024)

ChatGPT + Sheets usage (advanced):

  1. You’ll need an OpenAI account.
  2. Create a new Google Sheet (you can use https://sheets.new).
  3. Extensions > Apps Script.
  4. Overwrite all text in the text box by pasting all the code below.
  5. Retrieve your new secret key (sk-xxx) from https://platform.openai.com/account/api-keys
  6. Paste your new secret key (sk-xxx) into the script as indicated.
  7. Click Save and Run icons. Authorise the application if needed.
  8. Close the script window. Back in your new sheet, as an example, type “France” into A1. Then type this formula into B1: =IF(ISBLANK(A1),,GPT("The capital of "&A1&" is (name only):"))

OR: Use my new Sheets template:
2023-ChatGPT-Sheets-Template-For-Workshops

/*** ChatGPT and Google Sheets* https://lifearchitect.ai/sheets/* Revision 20230305 valid until 2024 subject to OpenAI API and model changes** @param {string} prompt Prompt.* @param {number} temperature (Optional) Temperature.* @param {string} model (Optional) GPT-3 chat Model.* @return Response returned by GPT-3 chat.*/const SECRET_KEY = "sk-paste-your-API-secret-key-here";const MAX_TOKENS = 10; // around 40 characters, increase for more output, with increasing $const MODEL_NAME = "gpt-3.5-turbo"; // ChatGPTconst MODEL_TEMP = 0.3;function GPT(prompt, temperature = MODEL_TEMP, model = MODEL_NAME) { const url = "https://api.openai.com/v1/chat/completions"; const payload = { model: model, messages: [ { role: "system", content: "" }, // blank priming prompt for lower token count { role: "user", content: "" + prompt }, ], temperature: temperature, max_tokens: MAX_TOKENS, }; const options = { contentType: "application/json", headers: { Authorization: "Bearer " + SECRET_KEY }, payload: JSON.stringify(payload), }; const res = JSON.parse(UrlFetchApp.fetch(url, options).getContentText()); return res.choices[0].message.content.trim();}

1/Mar/2023: Updated to use ChatGPT. As of 1/Mar/2023, the script above uses OpenAI’s new ChatGPT as gpt-3.5-turbo via API for this functionality using the new chat completion endpoint., with a cost 10x lower than standard text-davinci-003. The original script using the older model is below, and could be adapted to use GPT-4.

View the older code for text-davinci-003 (10x more expensive)

/*** GPT-3 and Google Sheets* https://lifearchitect.ai/sheets/** @param {string} prompt Prompt.* @param {number} temperature (Optional) Temperature.* @param {string} model (Optional) GPT-3 Model.* @return Response returned by GPT-3.* @customfunction*/const SECRET_KEY = "sk-paste-your-API-secret-key-here";const MAX_TOKENS = 10;const MODEL_NAME = "text-davinci-003"; // more structured and deterministic: for data//const MODEL_NAME = "davinci"; // more flexible and creative: for stories, chatbotsconst MODEL_TEMP = 0.3;function GPT(prompt) { const url = "https://api.openai.com/v1/completions"; const payload = { model: MODEL_NAME, prompt: prompt, temperature: MODEL_TEMP, max_tokens: MAX_TOKENS, }; const options = { contentType: "application/json", headers: { Authorization: "Bearer " + SECRET_KEY }, payload: JSON.stringify(payload), }; const res = JSON.parse(UrlFetchApp.fetch(url, options).getContentText()); return res.choices[0].text.trim();}

GPT-3 and Google Sheets (2024)
Top Articles
Aptitude test | IQ, Cognitive Ability & Problem-Solving
Why candidate aptitude assessments matter - TG
Northern Counties Soccer Association Nj
Nybe Business Id
Bild Poster Ikea
Parke County Chatter
J & D E-Gitarre 905 HSS Bat Mark Goth Black bei uns günstig einkaufen
Ret Paladin Phase 2 Bis Wotlk
10 Popular Hair Growth Products Made With Dermatologist-Approved Ingredients to Shop at Amazon
Bellinghamcraigslist
biBERK Business Insurance Provides Essential Insights on Liquor Store Risk Management and Insurance Considerations
Craigslistdaytona
What is a basic financial statement?
Guardians Of The Galaxy Vol 3 Full Movie 123Movies
Hillside Funeral Home Washington Nc Obituaries
Gfs Rivergate
978-0137606801
How to find cash from balance sheet?
9044906381
National Weather Service Denver Co Forecast
Procore Championship 2024 - PGA TOUR Golf Leaderboard | ESPN
London Ups Store
Uky Linkblue Login
Craigslist List Albuquerque: Your Ultimate Guide to Buying, Selling, and Finding Everything - First Republic Craigslist
UPS Store #5038, The
The Ultimate Guide to Extras Casting: Everything You Need to Know - MyCastingFile
Rufus Benton "Bent" Moulds Jr. Obituary 2024 - Webb & Stephens Funeral Homes
Titanic Soap2Day
Jeffers Funeral Home Obituaries Greeneville Tennessee
What Are The Symptoms Of A Bad Solenoid Pack E4od?
Wku Lpn To Rn
Penn State Service Management
Elijah Streams Videos
Quality Tire Denver City Texas
Shaman's Path Puzzle
Maybe Meant To Be Chapter 43
Terrier Hockey Blog
Boggle BrainBusters: Find 7 States | BOOMER Magazine
Mcgiftcardmall.con
Check From Po Box 1111 Charlotte Nc 28201
Cygenoth
Gvod 6014
Indiana Jones 5 Showtimes Near Cinemark Stroud Mall And Xd
PruittHealth hiring Certified Nursing Assistant - Third Shift in Augusta, GA | LinkedIn
Www Usps Com Passport Scheduler
Fwpd Activity Log
Gw2 Support Specter
Stitch And Angel Tattoo Black And White
Neil Young - Sugar Mountain (2008) - MusicMeter.nl
3367164101
Latest Posts
Article information

Author: Francesca Jacobs Ret

Last Updated:

Views: 6280

Rating: 4.8 / 5 (68 voted)

Reviews: 91% of readers found this page helpful

Author information

Name: Francesca Jacobs Ret

Birthday: 1996-12-09

Address: Apt. 141 1406 Mitch Summit, New Teganshire, UT 82655-0699

Phone: +2296092334654

Job: Technology Architect

Hobby: Snowboarding, Scouting, Foreign language learning, Dowsing, Baton twirling, Sculpting, Cabaret

Introduction: My name is Francesca Jacobs Ret, I am a innocent, super, beautiful, charming, lucky, gentle, clever person who loves writing and wants to share my knowledge and understanding with you.