Google Spreadsheet + GPT3

Hi @notifications
The gsheet is currently used for managing data between the Embeddings API and Completion API. Currently it is not designed for the FineTuning API. From my experience most uses cases don’t need the Fine Tuning API, what are you looking to do with OpenAI’s API library?

Thank you Nelson for a quick reply

I have made an end to end app using google app script as backend language and used app sheet for front end and google sheet for database.

Now I have already integrated the app with Open AI api for some of the use case.

Now I want to fine tune the model with the data captured by the app during the operation of the business.

I have never worked on python the only language I know is google app script.

Hi @notifications
For the fine tuning API, I don’t have plan on integrating with the current Google Sheet at the moment but you can follow the direction here to do it. OpenAI API

Hi Nelson,
I already trained my model by reading documentation and steps and all instructions related doubts were asked to Chat GPT itself. Learning is so easy with the help of AI… it is substantially increasing implementation process.

Thank you for your time.

Glad to hear you have made progress in such a short time. Well done!!!

I am trying to use your script and am getting an error as if the default API key of “xxxx” is still in use. The API key is valid because I have another Gsheet that makes calls to OpenAPI and it works.
ScreenHunter 3783

After you modify the API key it won’t trigger the function yet.
Have you tried updating the cells with the input?

I tried to troubleshoot it. In the end, I found another Google Sheet that worked.

Sorry to hear that it didn’t work for you, best of luck to your project.

Hi, do you mind drop the link for the Google Sheet that worked? I make a copy of the Google Sheet and face the same issue as you mentioned in previous post.

I found out how to make it work. Need to click appscript and approve the permission and then it works perfectly.

Thanks. I’ll take another look. Here is the script that worked for me:

const SECRET_KEY = “”;
const MAX_TOKENS = 200;
const gpt_model = “text-davinci-003”

function OpenAI(prompt, temperature = 0.7, model = gpt_model) {
const url = “https://api.openai.com/v1/completions”;
const payload = {
model: model,
prompt: 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].text.trim();
}

I made a new copy of the Google Sheet and tried it again. I accepted the security settings, but no luck. I must have some other weird setting.

Hi @johnfaig

Can you also check if you are

  1. Using this latest version of the sheet
    GPT3-On-Custom-Data - Google Sheets
  2. Using the api key without the Bearer keyword, meaning that it should only contain the value sk-xxxxxxxxxx

Thanks for your help. It works now.

I made a copy of the Google Sheet from the link you just provided. I’m not sure if it was a previous version, but you need to do some serious editing to your sample formulas. For example, simply pressing [F2] to edit and pressing [ENTER] doesn’t cut it. I added a leading apostrophe to make it a text label and then removed it and that worked. In some cases, I’ve copied formulas around. It seems like Google Shhet might have some caching.

Good to know that you were able to get it up and running.
Cheers!

This sheet has been super helpful for our experiments. Just want to flag that it looks like it may need some updates to support the just recently updated ChatGPT. It seems the API endpoint is slightly different for those models.

FYI the docs for that are here, including how to use ChatGPT for the completion use case:

Thanks for sharing Matt.
Right now it’s running at the text-davinci-003 model, I’ll definitely test out the new ChatGPT model as well and making changes on the default setting tab. Have you tested it out yet?
What is your experience in the new ChatGPT model?

I haven’t had a chance to play with ChatGPT via API, but I’ve done side-by-side comparisons with davinci-003 in API vs ChatGPT in browser and in our use cases it’s been night and day in response quality. I’ve been waiting for the day we can plugin ChatGPT instead.

I think for the sheets version you will probably want a new “Chat Completions” sheet and a new setting under Settings for the chat model. Reason is that it’s a slightly different API end point and a slightly different parameter format so the GPT3 and the chat models aren’t interchangeable. Then have a separate sheets function that accepts a range of cells rather than a single value, to correspond to the array that the API endpoint accepts.

Spitballing here, but that should work (I’ve never written scripts for sheets)

Hi everyone.
I have updated the Google Sheet + GPT3 to support the new ChatGPT API.
When running on the new ChatGPT API, you can reduce your cost by 10 times and get much safer responses, so I would highly recommend you to do the upgrade.
Also I have kept this google sheet in the same structure as the old one, so it should be be fairly easy if you are migrating from the old sheet to this new one. Good luck on your AI journey and please comment below and share your results. Cheers!