Select ChatGPT completion with longest response

I am using the OpenAI make application to generate GPT4 chat completions.

I have set the “number” property to “3” which generates three completions to my one prompt.

I would like to evaluate these three chat completions by character length, and move forward with the longest reply.

Any suggestions on how to achieve this?

1 Like

Hi Sam,

I think one solution would be to iterate through these completions, create a variables length(completion) and then put this into an array using the array aggregator. Then you sort this array by this length variable and only use the first item.

Modules would be

  1. ChatGPT
  2. iterator
  3. set variable
    4 array aggregator
    → whatever you want to do with the response

Welcome to the Make community!

Yes, that is possible. You’ll need a minimum of four modules:

Iterate choices array

Add length variable

Sort by length variable and pop first item.

Give it a go and let us know if you have any issues!