From 555ccfb8d1cb5087e4a5db0c2476edba3be12000 Mon Sep 17 00:00:00 2001 From: Roger Gonzalez Date: Mon, 18 Sep 2023 18:54:23 -0300 Subject: [PATCH] Better placement for the recursion catcher --- chatgpt_helper.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/chatgpt_helper.py b/chatgpt_helper.py index db965bf..395239f 100644 --- a/chatgpt_helper.py +++ b/chatgpt_helper.py @@ -147,14 +147,14 @@ async def get_chatgpt_html_response(topic: str = None, count: int = 0) -> str: """ count += 1 + if count >= 5: + return f"Error! ChatGPT is having problems with this topic: {topic}. Try a new one." + if topic is None: topic = await get_random_topic() html = prompt_html_template.replace("(topic)", topic) - if count >= 5: - return f"Error! ChatGPT is having problems with this topic: {topic}. Try a new one." - logging.info(f"The topic to generate is {topic}") try: