From d7d7183a84a1c78b794e6a3479569de480408f8c Mon Sep 17 00:00:00 2001 From: Codex Date: Sat, 7 Jun 2025 04:02:23 +0000 Subject: [PATCH] Add appeal AI test command --- cogs/aimod_cog.py | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/cogs/aimod_cog.py b/cogs/aimod_cog.py index 5a129e2..2c885be 100644 --- a/cogs/aimod_cog.py +++ b/cogs/aimod_cog.py @@ -2652,6 +2652,49 @@ CRITICAL: Do NOT output anything other than the required JSON response. ) print(f"Error in aidebug_last_decisions command: {error}") + @debug_subgroup.command( + name="appeal_tests", + description="Run sample appeals through the AI reviewer (admin only).", + ) + @app_commands.checks.has_permissions(administrator=True) + async def aidebug_appeal_tests(self, interaction: discord.Interaction): + """Run a few hardcoded appeals through the appeal AI for testing.""" + scenarios = [ + ( + "WARN", + "I was warned for spamming but I only sent a few messages quickly.", + ), + ( + "MUTE", + "I was muted for hate speech but it was just a meme quote, not harassment.", + ), + ( + "BAN", + "I was banned for posting NSFW art in the NSFW channel. It wasn't porn.", + ), + ] + + results = [] + guild = interaction.guild + for action, text in scenarios: + review = await self.run_appeal_ai(guild, interaction.user, action, text) + results.append((action, text, review)) + + embed = discord.Embed( + title="Appeal AI Test Results", color=discord.Color.green() + ) + embed.timestamp = discord.utils.utcnow() + + for idx, (action, text, review) in enumerate(results, 1): + value = ( + f"**Action:** {action}\n**Appeal:** {text}\n**AI Verdict:** {review}" + ) + if len(value) > 1024: + value = value[:1020] + "..." + embed.add_field(name=f"Scenario {idx}", value=value, inline=False) + + await interaction.response.send_message(embed=embed, ephemeral=True) + # Setup function required by discord.py to load the cog async def setup(bot: commands.Bot):