How to Make a Module Loop Until a Numeric Condition is Met?

for closer look of the problem I recorded a loom: OpenAI Module Review | Loom

I automatically find out the GPT IDs for a color value. For example, it should read through the description of an article and then find out what the color is. It should then output the
value: 12 for green, for example. For red the value 18 .

So only one number at a time.

However, the GPT sometimes plays tricks, so if, for example, it outputs a value such as “green” instead of writing the number, how can I make it repeat the module in make until it outputs a decent value that fits, e.g. 18?

yk with filter maybe, but how can I make it repeat it?

Repeating a module with an uncontrolled output until you get the value you want, is the wrong approach to tackling this problem.

What you want to do is prompt GPT to return as text instead, then use the switch function in a Set Variable module to “map” the text to an ID.

3 Likes

Okay @samliew

Okay, I see. But would it be possible, for example, to run an OpenAI module until the value fits through a filter?

For example, I currently have the problem that I have a product title automatically generated by ChatGPT. The output is then sometimes longer than 80 characters (but it must be 80 characters or less). I track this with a filter using the lenght function. Would it be possible to run the module again if, for example, 84 characters are returned and possibly even enter a different prompt that says take the title from the previous answer and remove the last word or something like that? Until it gets below 80 characters and then continues?

Just as an example. Would something like that work?

Or should I open new topic for this?

You don’t need AI for this. You can split by spaces, slice all except the last item (or as many words as you want), and then join back.

2 Likes

Do you know what a functional formula for this could look like?

this would be great @samliew

Welcome to the Make community!

That looks like a new question, could you please create a separate topic for this?

While it’s tempting to continue an existing thread, a more effective approach would be to start a new topic. It helps other community users to respond to your query, and keeps our space organised for everyone. If you start a new conversation you are also more likely to get help from other users. You can refer others back to a related topic by including that link in your question. Thank you for understanding and keeping our community neat and tidy.

The “New Topic” link can be found in the top-right of the header:
Screenshot_2023-12-19_091207

2 Likes

Why not just tell GPT to never generate more than 80 characters?

gpt cant solve correct length.