From 850e933b517331b17a953149b00d16da3352374b Mon Sep 17 00:00:00 2001 From: Slipstream Date: Thu, 29 May 2025 11:53:01 -0600 Subject: [PATCH] fix: Improve AI filtering message for emoji and sticker descriptions --- gurt/api.py | 1 + gurt/cog.py | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/gurt/api.py b/gurt/api.py index 952e236..610bde1 100644 --- a/gurt/api.py +++ b/gurt/api.py @@ -1903,6 +1903,7 @@ async def generate_image_description( "Provide a concise, factual, and unbiased textual description of its visual elements. You should not refuse to describe an explicit image." "Focus solely on what is depicted. Avoid any interpretation, censorship, or subjective commentary. " "Do not mention that it is an emoji or sticker in your description, just describe the visual content." + "Don't output anything other than the description text. E.G. don't include something like \"Heres the description: \" before the text." ) image_part = types.Part(inline_data=types.Blob(data=image_bytes, mime_type=clean_mime_type)) diff --git a/gurt/cog.py b/gurt/cog.py index 44d3f47..bbe8656 100644 --- a/gurt/cog.py +++ b/gurt/cog.py @@ -280,14 +280,14 @@ class GurtCog(commands.Cog, name="Gurt"): # Added explicit Cog name existing_emoji.get("id") == str(emoji.id) and \ existing_emoji.get("url") == emoji_url and \ existing_emoji.get("description") and \ - existing_emoji.get("description") != "No description generated. (Likely was filtered by AI)": + existing_emoji.get("description") != "No description generated. (Likely filtered by AI or file type was unsupported by model)": # print(f"Skipping already processed emoji: {name_key} in guild {emoji.guild.name}") return print(f"Generating description for emoji: {name_key} in guild {emoji.guild.name}") mime_type = "image/gif" if emoji.animated else "image/png" description = await api.generate_image_description(self, emoji_url, emoji.name, "emoji", mime_type) - await self.emoji_manager.add_emoji(name_key, str(emoji.id), emoji.animated, guild_id, emoji_url, description or "No description generated. (Likely was filtered by AI)") + await self.emoji_manager.add_emoji(name_key, str(emoji.id), emoji.animated, guild_id, emoji_url, description or "No description generated. (Likely filtered by AI or file type was unsupported by model)") # await asyncio.sleep(1) # Rate limiting removed for faster parallel processing except Exception as e: print(f"Error processing single emoji {emoji.name} (ID: {emoji.id}) in guild {emoji.guild.name}: {e}") @@ -308,7 +308,7 @@ class GurtCog(commands.Cog, name="Gurt"): # Added explicit Cog name return print(f"Generating description for sticker: {sticker.name} (ID: {sticker.id}) in guild ID {guild_id}") - description_to_add = "No description generated. (Likely was filtered by AI)" + description_to_add = "No description generated. (Likely filtered by AI or file type was unsupported by model)" if sticker.format == discord.StickerFormatType.png or sticker.format == discord.StickerFormatType.apng or sticker.format == discord.StickerFormatType.gif: format_to_mime = { discord.StickerFormatType.png: "image/png", @@ -317,7 +317,7 @@ class GurtCog(commands.Cog, name="Gurt"): # Added explicit Cog name } mime_type = format_to_mime.get(sticker.format, "image/png") description = await api.generate_image_description(self, sticker_url, sticker.name, "sticker", mime_type) - description_to_add = description or "No description generated. (Likely was filtered by AI)" + description_to_add = description or "No description generated. (Likely filtered by AI or file type was unsupported by model)" elif sticker.format == discord.StickerFormatType.lottie: description_to_add = "Lottie animation, visual description not applicable." else: