Mastering OpenAI: Re-run Module Until Condition Met

Have you ever faced a situation where you needed to re-run a module until a certain condition is met? Well, you're not alone. I recently encountered a similar challenge while working with the OpenAI module. My goal was to re-execute the OpenAI module whenever the response length exceeded 3000 characters, which is the limit for LinkedIn posts. I wanted to repeat this process until the response length from the OpenAI module was less than 3000 characters.

Problem

The problem was that OpenAI doesn’t know how to count words, it counts chunks of words which can be a few letters or a whole word. So, setting a maximum token limit in the GPT module in advanced settings wasn't a foolproof solution. Even if I set the maximum tokens to 500, it could still exceed 3000 characters.

Solution

After some trial and error, I found a solution. I included a “repeater module” that keeps trying something until the response it gets is shorter than 3000 characters. So, whenever the content length meets the required standards, it gets posted on my LinkedIn profile. To make sure this process doesn’t go on indefinitely (repeater), I introduced an “HTTP module” that connects to a non-existent web address. It will give an expected error and to handle that error add commit module to it.

Troubleshooting Tips

If you're facing a similar issue, here are some tips that might help:

  • Try setting a maximum token limit in the GPT module in advanced settings. This might not always work, but it's worth a try.
  • Consider using a repeater module to keep trying until the response meets your requirements.
  • If the process goes on indefinitely, introduce an HTTP module that connects to a non-existent web address. This will give an expected error and you can handle that error with a commit module.

Conclusion

In conclusion, while it might seem challenging at first, with a bit of creativity and persistence, you can find a solution to re-run a module until a certain condition is met. I hope this article was helpful and encourages you to keep exploring and experimenting with different modules and settings. Remember, every problem has a solution, you just need to find it!

You do have further questions?

Ask your question via E-Mail: Richard@make-app.de
Book a paid Support & Consulting Session
New Make.com user? Sign up through this Affiliate Link to receive 10.000 operations for FREE.