From 0df49e7934a4abd4ff17fb873b66460d2d2b8a35 Mon Sep 17 00:00:00 2001 From: Luke Robles Date: Wed, 10 Apr 2024 20:17:50 -0700 Subject: [PATCH] Split long answers into two mesages --- app/bot.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/bot.py b/app/bot.py index 0613c961..5468bb03 100755 --- a/app/bot.py +++ b/app/bot.py @@ -213,7 +213,12 @@ async def on_message(ctx): response = requests.post(url, json=payload, headers=headers) answer = response.json()["choices"][0]["message"]["content"] - await ctx.reply(answer.replace("<|end_of_turn|>", "")) + + if len(answer) > 2000: + await ctx.reply(answer[:2000].replace("<|end_of_turn|>", "")) + await ctx.reply(answer[2000:].replace("<|end_of_turn|>", "")) + else: + await ctx.reply(answer.replace("<|end_of_turn|>", "")) bot.run(os.getenv("discord_token"))