Google Spreadsheet + GPT3

Wow, cool. Checking it out right now.

1 Like

Thanks, hope you like it, let me know if you have ideas on improving it…

1 Like

FYI, I created a new version for this as well with Embeddings API.

1 Like

Hi @nelson. Thanks for sharing this!

Is there a way where ChatGPT could answer prompt questions with responses from real-time data coming from my API? For example: if my API feeds real-time stock information could this be incorporated into the chatGPT interface?

You cant do this with ChatGPT right now because there is no API for it.

You could however, do something with GPT3 and a chat prompt. Even though it can’t get data from a specific end point, you could potentially train it up to answer questions and use placeholders in your training.

Eg the current stock price on the for Russell 2000 on the NYSE is ##price##

Then whenever you see ##price## in a response, you could swap it out with the data you get from making your own call to another service that provides stock prices

The real trick here is to figure out what the placeholder(s) should be to get it to appear inline on a reliable basis.

Eg. The ## may be intercepted by codex and it may start to think you are trying to write a program instead of asking a completion.

You may also be able to use a different placeholder for the trading stock name (Russell 2000)

You may even be able to do this using a few-shot prompt instead of training

Anyway, just some ideas to try (Nothing tested by me)

1 Like

Thanks for the explanation @raymonddavey. Probably I could reach the simple QA task with slot/placeholder filling however this is much cheaper with the some open-source QA model.
I will try a few-shot prompt this week and let you know how this turns out.

Best, Peter

1 Like

Hi @peter.nemec
That is a very interesting use case. As @raymonddavey has mentioned, there is no official ChatGPT API now but the new text-davinci-003 model is pretty close.
I think there are many ways you can approach this problem.

  1. You can get someone to integrate the API feeds with the GPT API for you, and with programing you can customize it however you like.
  2. The other approach is the use the spreadsheet above and pull the stock information into the google spreadsheet in near realtime. That involves a little programming too, but there are probably plugins that can help you do that.

For example feed such as MarketWatch.com - Real-time Headlines
can go into this sheet…

You can do use the Search to to find data and feed it into GPT Prompt like this…

The idea of using GPT to analyze stock trend for you on a spreadsheet is pretty cool.
Hope you make a lot of money!

3 Likes

Hi @nelson,

That was super fast. Thanks also for open-sourcing the google sheet.
Will try using your second approach to verify text-davinci-003 QA task before diving into unnecessary coding.

Best,
Peter

1 Like

You are welcome, good luck.
Feel free to reach out if you hit a roadblock.

1 Like

Thanks a lot @nelson

I’ve been working on a sheet similar to yours. It does work and generate the GPT3 response. My problem is that the formulas re-execute/prompt a response whenever I reopen the sheet. So, consuming additional tokens.

I checked your script, but I’m not sure if it prevents this issue. If so, how?

Thanks again.

2 Likes

Hi @SilverH
Thanks for sharing that, from what I can tell, it will only trigger the API call when the cell id modified. Let me check if there are other actions that can cause re-executing the prompt. Will keep you posted.

1 Like

Thanks for the prompt reply.

The issue is with my own script. I was wondering if you were experiencing a similar problem. I haven’t tried your script yet. If there is no problem, I can start using yours with some modifications.

1 Like

Hi @SilverH,
Maybe I can help you take a look at it? Do you mind sending over that to me?

1 Like

@nelson I have a solution to preserve outputs and prevent unnecessary burning of tokens. Would love to connect to share with you here. Also have a question for you about how you were able to leverage embeddings into google sheets. Thanks!

2 Likes

Hi all, just want to make a friendly reminder.
Some users have been getting issues on editing the Google Spreadsheet. Just wanted to say that by default the Google Spreadsheet is read-only, but you are more than welcome to make a copy of the google spreadsheet to your own drive and make any changes necessary.
Cheers!

2 Likes

Would be very grateful if you could share the solution to prevent unnecessary burning of tokens here!

1 Like

@songsofthespheres Are you using the newer version I posted here?

This one should not have any issues on burning tokens.
Also if you want to make sure, I added a new function call getCompletionsWithTimestamp
You can use this to test when was the last time the API executed.

2 Likes

Thanks Nelson. As far as I can tell, this now seems to be working for me!

I’ve noticed that the Search function only returns the entire text of the cell with the highest cosine similarity. Is there any way to make it so that the Search returns information from more than one cell (and not irrelevant information)?

I’m not much of a programmer so it is all a bit new to me. ChatGPT tells me I might consider using Named Entity Recognition based on spaCy, but wondering if you have any obvious workarounds.

What I am ultimately hoping to achieve is to fill the Sheets with my worldbuilding information then feed in relevant information into new prompts dynamically. Also, to have a summary cell for each category (e.g. a place) that I occasionally update using the Search function.

1 Like

Hi @songsofthespheres

I’m glad that you find it useful. As you mentioned, the search function was designed to only give you the result with the highest score. May I ask why the result with the highest score is giving you irrelevant information? I think we need to look into why that is happening, otherwise give you more results back might not help.

1 Like

Hi Nelson.

To give an example if cell one is ‘Alice is red’ and cell two is ‘Alice is tall’, when I ask ‘Describe Alex’ I get one or the other of those descriptors (red or tall) but never both. This is probably not a use that you intended the sheet to cover.

The reason Alice might be variously described in my use is because things in my world might be related. For example, a city may be mentioned in the context of more than one entry relating to a faction.

It may be that the solution is not in the code as such but in how I organise the data.

1 Like