From cf7b7b81096418c4e092b26ec02f47d34a3aa42b Mon Sep 17 00:00:00 2001 From: Codex Date: Sat, 7 Jun 2025 03:55:42 +0000 Subject: [PATCH] Add AI appeal testcases command --- cogs/aimod_cog.py | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/cogs/aimod_cog.py b/cogs/aimod_cog.py index 5a129e2..f22aeba 100644 --- a/cogs/aimod_cog.py +++ b/cogs/aimod_cog.py @@ -1091,6 +1091,48 @@ class AIModerationCog(commands.Cog): ) await interaction.response.send_message(embed=embed, ephemeral=False) + @appeal_subgroup.command( + name="testcases", + description="Run sample appeals through the AI review system (admin only).", + ) + async def appeal_testcases(self, interaction: discord.Interaction): + """Run a few hardcoded appeal scenarios through the AI.""" + if not interaction.user.guild_permissions.administrator: + await interaction.response.send_message( + "You must be an administrator to use this command.", + ephemeral=True, + ) + return + + scenarios = [ + ("Warn for spam", "I got excited and posted too many messages."), + ( + "Mute for harassment", + "I was only teasing my friend and didn't mean to harass anyone.", + ), + ( + "Ban for posting slurs", + "I'm sorry for what I said and promise it will not happen again.", + ), + ] + results: list[tuple[str, str]] = [] + for action, text in scenarios: + result = await self.run_appeal_ai( + interaction.guild, interaction.user, action, text + ) + results.append((action, result)) + + embed = discord.Embed( + title="Appeal AI Test Results", color=discord.Color.green() + ) + for action, result in results: + field_text = result if result else "No response" + if len(field_text) > 1000: + field_text = field_text[:997] + "..." + embed.add_field(name=action, value=field_text, inline=False) + + await interaction.response.send_message(embed=embed, ephemeral=True) + @model_subgroup.command( name="set", description="Change the AI model used for moderation (admin only)." )