From 1358f23c2db0108152b01c87d98ee717dcd77fc2 Mon Sep 17 00:00:00 2001 From: Yasir Aris M Date: Mon, 15 Jan 2024 06:44:55 +0700 Subject: [PATCH] Handle if prompt contain blacklist Signed-off-by: Yasir Aris M --- 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 10c59594..e78c8e79 100644 --- a/misskaty/plugins/chatbot_ai.py +++ b/misskaty/plugins/chatbot_ai.py @@ -55,7 +55,9 @@ async def gemini_chatbot(_, ctx: Message, strings): json=json_data, timeout=20.0, ) - await msg.edit_msg(response.json()["candidates"][0]["content"]["parts"][0]["text"]) + if response.json().get("promptFeedback"): + return await msg.edit_msg("⚠️ Sorry, the prompt you sent contains a forbidden word that is not permitted by AI.") + await msg.edit_msg(html.escape(response.json()["candidates"][0]["content"]["parts"][0]["text"])) except Exception as e: await msg.edit_msg(str(e))