Prevent repeats in ChatGPT results

Hey all

I’ve been using the Open AI integration to produce spelling lists, story prompts, maths questions and a bunch of other things. Really happy with how easy it’s been to set up and can see so much potential. The only issue is that it keeps repeating the same results, e.g. half of the spelling words from the first list are repeated when the action is run again.

I have tried a few things to solve the problem:

  1. Build the message prompt from a template that includes the previous answer and tell ChatGPT not to include anything from there. This was never going to work of course because it only stops repeats on the next run. After the next run it goes back to repeating items from the first list.

  2. Include an ‘Add Row’ action that writes the results to an archive table and relate that back to the message template. This works fairly well but I’d rather not write a row every time the action is used (I anticipate the action being used a lot if it’s ever set up properly).

  3. I tried the ‘Message ChatGPT with History’ action, but this didn’t change anything - could this work if set up correctly? I’m not sure how to leverage the history part or what it’s even supposed to do. Could it be used to prevent repeats?

This shouldn’t happen. Have you tried this in ChatGPT itself? I often find playing around there with my prompts helps me tweak it for use in Glide.

Not sure of your setup, but have you tried encouraging ChatGPT to take into account a history of what its suggested before?

1 Like

Hi, thanks for your reply. Yes, before I set it up in Glide I tested it directly and it worked after a couple of messages to tell it what I needed.

Inside Glide I’m using a button so the prompt needs to be honed in such a way that it works the first time (which is why testing first helps). But I’m trying to understand - if the action is ‘Send Message to ChatGPT without History’ - does the bot treat each request as new and cannot take into account what it’s given me previously?

I used both types of action (with history and without history) but it doesn’t make any difference.

I’m sure it’s an error in my set up as I kinda jumped in excitedly without knowing best practice. If I ask ChatGPT not to repeat words it has given in previous lists, do I add that to the prompt or the message? I’ve tried both.

image

I also wonder if it’s something to do with how I set up the columns for the ‘Send Message with History’ action - is this correct?

image

Hi, I don’t know if it answers directly to your question, but to prevent an action to re-run Gpt, what I did in my custom action is to create two columns to deal with the Gpt result:

  • column 1: run the Gpt api
  • wait for condition: “column 1” is not empty
  • column 2: set column value with “column 1”.

Then the component that I display is based on “column 2”.

Hope this helps

I think it’s running a new action each time. Maybe it just isn’t very good at not repeating word lists, at least for very basic 3-4 letter words. I just went back and properly tested inside ChatGPT. When I tested last night I asked for words that would suit an 11 year old and it did a pretty good job but that might be due to the fact it pulls from a larger range of words for that age group. I gets stuck when I set it to junior words (6 year olds) repeating cat, dog, pig nearly every time.

Have you tried adjusting the temperature and frequency penalty to make results more deterministic? It may help.

Yeah I had a few tries at various settings. The only thing I found was that when I set it to the extreme end it returned completely jumbled text. I’ll fiddle a bit more and see if it helps

I’m unsure how to set up the action for Message ChatGPT with History - it asks that I set the columns for message history, so I select the ones that I’ve already set up:

Do I leave it there, or do I have to add an action that writes to those columns? It’s a bit unclear reading the tool tips on what exactly I’m supposed to do.

image

You should add a new row to that table… looks like you are using the user profile tab… you’ll want a new dedicated table for this… for GPT with History

Now that you say it, it seems obvious - adding a row with a user ID so it can reference previous entries. It’s instantly made a difference. There are still a few repeats but it’s vastly improved. I guess the only problem is that this is what I tried in the original post and was hoping to avoid - adding a row with each run. I had it set up without history but it would reference an archive and avoid those entries

1 Like

I suppose it’s unrealistic to expect it to not repeat without adding rows otherwise it has no idea what to avoid. Wishful thinking on my part that there might be a way around it.

Ya the most straight forward way is to just add rows to a table. I’m working on a Chat Bot with history I could share when I’m finished :wink:

1 Like

Yep true, it’s easy enough to wipe the rows every couple of weeks anyway

1 Like

There is a way to do this without ever having to clear or delete any rows, as long as you can stick with a fixed number of rows - enough to cater for a single user session.

You just need a variation of Jeff Hager’s multirow reset technique. It would work as follows:

  • At the start of a session, set a Unique Identifier in a User Specific column in the first row
  • Use a Single Value column to apply that value to all rows
  • Each time you get a response from the AI, write it into another user specific column
  • At the same time use a Set Column values action to set the value in a 3rd User Specific column to be the same as the Single Value column.
  • Lastly, use an if-then-else column to determine which rows should count - only those where the two unique identifiers are a match

The only tricky part is moving down the table as you get each new response. But you can do that by using the same values to determine the “next available row”, build a single relation to that row, and then write values through that relation.

When you’re done, you can reset the whole table by simply setting a new unique identifier in the first user specific column.

2 Likes

How about saving the current chat and loading previous ones? I was thinking about storing each column of unique chats in a comma separated list or JSON and then exploding them with the miracle method… then use the helper table as the source for GPT with history.

What do you think?

Yeah, that could work.

1 Like

When you say have enough rows to cater for a single user session - can I cater for 20 or more users at once?

Because everything is user specific, you can cater for as many users at once as you can throw at it - all using the same set of rows.

ok wow, I’ll def have a go at setting that up