fix: Improve AI filtering message for emoji and sticker descriptions

This commit is contained in:
Slipstream 2025-05-29 11:53:01 -06:00
parent f07d569548
commit 850e933b51
Signed by: slipstream
GPG Key ID: 13E498CE010AC6FD
2 changed files with 5 additions and 4 deletions

View File

@ -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." "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. " "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." "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)) image_part = types.Part(inline_data=types.Blob(data=image_bytes, mime_type=clean_mime_type))

View File

@ -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("id") == str(emoji.id) and \
existing_emoji.get("url") == emoji_url and \ existing_emoji.get("url") == emoji_url and \
existing_emoji.get("description") 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}") # print(f"Skipping already processed emoji: {name_key} in guild {emoji.guild.name}")
return return
print(f"Generating description for emoji: {name_key} in guild {emoji.guild.name}") print(f"Generating description for emoji: {name_key} in guild {emoji.guild.name}")
mime_type = "image/gif" if emoji.animated else "image/png" mime_type = "image/gif" if emoji.animated else "image/png"
description = await api.generate_image_description(self, emoji_url, emoji.name, "emoji", mime_type) 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 # await asyncio.sleep(1) # Rate limiting removed for faster parallel processing
except Exception as e: except Exception as e:
print(f"Error processing single emoji {emoji.name} (ID: {emoji.id}) in guild {emoji.guild.name}: {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 return
print(f"Generating description for sticker: {sticker.name} (ID: {sticker.id}) in guild ID {guild_id}") 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: if sticker.format == discord.StickerFormatType.png or sticker.format == discord.StickerFormatType.apng or sticker.format == discord.StickerFormatType.gif:
format_to_mime = { format_to_mime = {
discord.StickerFormatType.png: "image/png", 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") 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 = 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: elif sticker.format == discord.StickerFormatType.lottie:
description_to_add = "Lottie animation, visual description not applicable." description_to_add = "Lottie animation, visual description not applicable."
else: else: