roast: use chat API with system prompt + few-shot example for actual biting roasts
Lint / Shell (shellcheck) (push) Successful in 13s
Lint / JS (eslint) (push) Successful in 7s
Lint / Python (ruff) (push) Successful in 4s
Lint / Python deps (pip-audit) (push) Successful in 40s
Lint / Secret scan (gitleaks) (push) Successful in 5s

Switch from api/generate to api/chat so we can set a system role that
instructs the model to be genuinely savage. Add a few-shot example so
it knows what a roast looks like vs a backhanded compliment.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-22 00:50:10 -04:00
parent acf68038d8
commit 83a4a2ffae
+19 -8
View File
@@ -1777,22 +1777,33 @@ async def cmd_roast(client: AsyncClient, room_id: str, sender: str, args: str):
lore = bio lore = bio
break break
lore_clause = f" Here is some context about them: {lore}" if lore else "" lore_clause = f"\nFacts about {display_name}: {lore}" if lore else ""
prompt = ( system_msg = (
f"You are a comedy roast writer for a group of friends who all consented to being roasted for fun. " "You are a savage comedy roast writer. Your job is to write brutal, funny, specific roasts. "
f"Write a savage, witty, 1-2 sentence roast of a person named {display_name}.{lore_clause} " "A roast is NOT a compliment. It makes fun of the person's job, habits, appearance, or life choices. "
f"Make it clever and specific. Output only the roast itself — no intro, no disclaimers, no apologies." "Example of a good roast of a gamer: 'You've spent so many hours grinding XP you forgot to grind IRL — "
"congrats on hitting level 30 while your credit score is still level 1.' "
"Rules: output ONLY the roast, 1-2 sentences max, no softening, no disclaimers, no 'but seriously', "
"no compliments hidden in the roast. Be mean but funny."
) )
user_msg = f"Write a roast of {display_name}.{lore_clause}"
try: try:
timeout = aiohttp.ClientTimeout(total=30) timeout = aiohttp.ClientTimeout(total=30)
async with aiohttp.ClientSession(timeout=timeout) as session: async with aiohttp.ClientSession(timeout=timeout) as session:
async with session.post( async with session.post(
f"{OLLAMA_URL}/api/generate", f"{OLLAMA_URL}/api/chat",
json={"model": BALL_MODEL, "prompt": prompt, "stream": False}, json={
"model": BALL_MODEL,
"stream": False,
"messages": [
{"role": "system", "content": system_msg},
{"role": "user", "content": user_msg},
],
},
) as response: ) as response:
data = await response.json() data = await response.json()
roast = data.get("response", "").strip() roast = data.get("message", {}).get("content", "").strip()
if not roast: if not roast:
raise ValueError("Empty roast response") raise ValueError("Empty roast response")
except Exception as e: except Exception as e: