From c99815ce044f56588f20e801691473c8acb2d301 Mon Sep 17 00:00:00 2001 From: Yasir Aris M Date: Wed, 31 Jul 2024 11:14:12 +0700 Subject: [PATCH] Fix stream response --- misskaty/plugins/chatbot_ai.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/misskaty/plugins/chatbot_ai.py b/misskaty/plugins/chatbot_ai.py index fba81631..57e1ebe2 100644 --- a/misskaty/plugins/chatbot_ai.py +++ b/misskaty/plugins/chatbot_ai.py @@ -83,7 +83,7 @@ async def openai_chatbot(_, ctx: Message, strings): stream=True, ) async for chunk in response: - if not chunk.choices[0].delta.content: + if not chunk.choices: continue num += 1 answer += chunk.choices[0].delta.content @@ -91,7 +91,7 @@ async def openai_chatbot(_, ctx: Message, strings): await msg.edit_msg(html.escape(answer)) await asyncio.sleep(1.5) num = 0 - await msg.edit_msg(html.escape(answer)) + 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}")