From 6bd5d9990e13312d7209efea695d5db36547f344 Mon Sep 17 00:00:00 2001 From: Yasir Aris M Date: Wed, 31 Jul 2024 11:18:18 +0700 Subject: [PATCH] Fix None object --- misskaty/plugins/chatbot_ai.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/misskaty/plugins/chatbot_ai.py b/misskaty/plugins/chatbot_ai.py index 57e1ebe2..143a7401 100644 --- a/misskaty/plugins/chatbot_ai.py +++ b/misskaty/plugins/chatbot_ai.py @@ -85,13 +85,15 @@ async def openai_chatbot(_, ctx: Message, strings): async for chunk in response: if not chunk.choices: continue + if not chunk.choices[0].delta.content: + continue num += 1 answer += chunk.choices[0].delta.content if num == 30: await msg.edit_msg(html.escape(answer)) await asyncio.sleep(1.5) num = 0 - await msg.edit_msg(html.escape(f"{answer}\n\nPowered by: GPT 4o")) + await msg.edit_msg(html.escape(f"{answer}\n\nPowered by: GPT 4o")) except MessageTooLong: answerlink = await post_to_telegraph( False, "MissKaty ChatBot ", html.escape(f"{answer}")