From 19dd6c9c62725956308f715882e4203e5ed411f8 Mon Sep 17 00:00:00 2001 From: Paillat Date: Wed, 2 Aug 2023 10:49:25 +0200 Subject: [PATCH] fix(makeprompt.py): fix issue where long response content is not fully sent in chatgpt_process function The issue was that when the response content was longer than 2000 characters, it was not being fully sent in the chatgpt_process function. This was fixed by adding a loop to send the content in chunks of 2000 characters until the entire content is sent. --- src/makeprompt.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/makeprompt.py b/src/makeprompt.py index 55f81e4..68a2cd5 100644 --- a/src/makeprompt.py +++ b/src/makeprompt.py @@ -169,6 +169,14 @@ async def chatgpt_process( "The function call is empty. Please retry.", delete_after=10 ) else: + content = response.get("content", "") + while len(content) != 0: + if len(content) > 2000: + await message.channel.send(content[:2000]) + content = content[2000:] + else: + await message.channel.send(content) + content = "" await message.channel.send(response["content"]) # type: ignore