Experiment with LLMs in Google Sheets
Interact with Gemini in Google Sheets and chain sheets together to link multiple prompts
Introduction
When I was at Google I wanted my product management team to get some hands on experience with LLMs so in our last offsite I setup a short LLM hackathon. Many of them had heard about LLMs but hadn't actually used them, or had briefly chatted with ChatGPT or Gemini but didn't really have a visceral sense for what they were capable of.
I gave them a set of prototyping tools to pick from including several internal Google tools and then one that I had made myself, which integrated Google's Gemini LLM directly into Google Sheets. My hypothesis was that Sheets would be the fastest way for most of them to get up and running given that they were already familiar with the UI. And that combining the power of Sheets with an LLM would unlock some interesting new possibilities.
It turned out that most teams did end up using the Sheets integration I had built. And they came up with some fun ideas :)
I rebuilt that integration and am sharing it here for anyone to use.
It's basically a baby version of Ask Steve. It enables you to create prompts with variables, change the variables, run the prompts without leaving Sheets, and even chain prompts together by referencing cells in other sheets.
It's a great way to get people who haven't played much with LLMs to dip a toe in the water with a familiar interface. It's also great for building sequential workflows with chained prompts. Give it a try, it's free!
Walkthrough Video
Instructions
- Make your own copy of this Google Sheet.
- From the copy dialog you can review the attached script to ensure that it's not doing anything it shouldn't be. You can also review the code here
- In your new spreadsheet, enter your Google Gemini API Key on the SETUP sheet in cell A1. Get one for free!
- To test that it's working, go to the second sheet and then select
Run
from theSheets LLM
menu. It may take the menu a few moments to appear. The first time you select it, you will need to give the script access permissions to Sheets and to make external calls. You might see a scary looking dialog that says "Google hasn't verified this app". You will need to click on theAdvanced
link and thenGo to Sheets LLM (unsafe)
. - You will need to select the menu item a second time after giving permissions. The Result field should fill in with the results.
- Try your own prompts and adjusting the temperature between 0.0 and 1.0. You can put variables in your prompts by surrounding them with double-brackets like [[this]]. Then you can put the values for your variables in the cells below. See the examples in the sample sheets.
- You can chain LLM calls using multiple sheets. Note that the "2. Write a press release" sheet is taking the result from the "1. Generate product ideas" sheet and using it as a variable for a second prompt. And similarly, the "3. Suggest visuals" sheet is using the press release as an input. You will need to
Run
on each sheet to update it. Add as many new sheets as you like to this doc and run them independently or chain them together. - Any live data that Sheets can import can be sent to Gemini. As an example the "Google News Feed" sheet reads the Google News rss feed and updates once an hour. Then the "Generate a movie plot from the news" sheet pulls the top news as variables and sends it to Gemini to create a movie plot.
- Feel like modifying the script that powers all this? Under the "Extensions" menu select "Apps Script" to access it. It is your own copy of the script that is attached to this specific doc, so feel free to make changes.
- This is using the publicly accessible Gemini API. Your input and output data can be used to improve Gemini. Do not send it any sensitive or confidential information.
Want to unlock the power of ChatGPT and Gemini in any web page? Install Ask Steve Now