Skip to content
Notifications
Clear all

Just built a Slack bot that generates memes with SD. Code on GitHub.

2 Posts
2 Users
0 Reactions
4 Views
(@night_owl_sre_88)
Eminent Member
Joined: 5 months ago
Posts: 22
Topic starter   [#1838]

Built a Slack bot that generates memes using Stable Diffusion. It's a runbook for fun. Serves as a concrete example of integrating SD into an ops workflow for on-call morale.

Key components:
- Listens for slash command like `/meme "caption text"`
- Uses the AUTOMATIC1111 API.
- Basic prompt engineering: `"a meme about: {user_input}, digital art, humorous, simple background"`
- Posts the generated image back to the channel.

Primary logic is in the slash command handler:

```python
def generate_meme(text):
payload = {
"prompt": f"a meme about: {text}, digital art, humorous, simple background",
"negative_prompt": "ugly, blurry, text, watermark, signature",
"steps": 20,
"width": 512,
"height": 512
}
response = requests.post(f"{SD_API_URL}/sdapi/v1/txt2img", json=payload)
return response.json()['images'][0]
```

Pitfall: Rate limiting Slack and the SD API. Implemented a simple token bucket. Another: Inconsistent image quality. Added a retry with a modified prompt.

Code is on GitHub. Useful for seeing how to handle async image generation in a chatops context.


null


   
Quote
(@consultant_carl_42)
Estimable Member
Joined: 2 months ago
Posts: 127
 

Neat trick for the slash command, and I'm sure it's a hit for on-call morale. But I'm staring at that `retry with a modified prompt` note and having war flashbacks to the "just one more API call" black hole.

You've got the token bucket, which is smart, but the real cost isn't just the Slack rate limit. It's the unpredictable spin-up time and resource drain on that AUTOMATIC1111 instance when six people decide to meme about the same P1 outage at once. Async generation in a chatops context is fine until someone's waiting 45 seconds for a blurry picture of a server on fire and the channel devolves into spamming the command.

Have you thought about a pre-generated fallback library? Even a simple one - like, if the first gen fails or times out, it posts a static meme template with the user's text slapped on it via PIL. The goal is the morale boost, not the art critique. Chasing consistency from an open-ended SD prompt in a production comms tool is a rabbit hole.

Also, and maybe I'm just paranoid from vendor contracts, but have you cleared the use of generated images for commercial/internal comms with your legal team? Some of those SD licenses are fuzzier than the outputs.


Test the migration.


   
ReplyQuote