wyr/riddle: add model attribution + fix truncated WYR options
wyr: - Reject options that end on a dangling word (but/and/or/with/never etc.) so truncated sentences like 'but never' return None and retry - Add 'via Llama 3.2 3B (abliterated)' credit to the poll message riddle: - Add 'via Llama 3.2 3B (abliterated)' credit to the riddle message Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+10
-5
@@ -1692,10 +1692,13 @@ async def _generate_wyr() -> dict | None:
|
|||||||
parsed = json.loads(text)
|
parsed = json.loads(text)
|
||||||
a = parsed.get("option_a", "").strip()
|
a = parsed.get("option_a", "").strip()
|
||||||
b = parsed.get("option_b", "").strip()
|
b = parsed.get("option_b", "").strip()
|
||||||
# Hard cap: truncate options that are too long
|
_HANGING = {"but", "and", "or", "with", "for", "in", "on", "at",
|
||||||
|
"the", "a", "an", "never", "always", "no", "not", "to",
|
||||||
|
"of", "by", "from", "that", "which", "who", "be", "have"}
|
||||||
if a and b:
|
if a and b:
|
||||||
a = " ".join(a.split()[:10])
|
# Reject if either option ends on a dangling word (truncation artifact)
|
||||||
b = " ".join(b.split()[:10])
|
if a.split()[-1].lower() in _HANGING or b.split()[-1].lower() in _HANGING:
|
||||||
|
return None
|
||||||
q = f"Would you rather {a.rstrip('.')} OR {b.rstrip('.')}?"
|
q = f"Would you rather {a.rstrip('.')} OR {b.rstrip('.')}?"
|
||||||
return {"question": q, "option_a": a, "option_b": b}
|
return {"question": q, "option_a": a, "option_b": b}
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@@ -1724,7 +1727,8 @@ async def cmd_wyr(client: AsyncClient, room_id: str, sender: str, args: str):
|
|||||||
f'<em>{wyr["question"]}</em><br><br>'
|
f'<em>{wyr["question"]}</em><br><br>'
|
||||||
f'🅰️ <strong>{wyr["option_a"]}</strong><br>'
|
f'🅰️ <strong>{wyr["option_a"]}</strong><br>'
|
||||||
f'🅱️ <strong>{wyr["option_b"]}</strong><br><br>'
|
f'🅱️ <strong>{wyr["option_b"]}</strong><br><br>'
|
||||||
f'<em>React with 🅰️ or 🅱️ — results in 30 seconds!</em>'
|
f'<em>React with 🅰️ or 🅱️ — results in 30 seconds!</em><br>'
|
||||||
|
f'<sup><em>via {_model_label(BALL_MODEL)}</em></sup>'
|
||||||
)
|
)
|
||||||
resp = await send_html(client, room_id, plain, html)
|
resp = await send_html(client, room_id, plain, html)
|
||||||
|
|
||||||
@@ -1871,7 +1875,8 @@ async def cmd_riddle(client: AsyncClient, room_id: str, sender: str, args: str):
|
|||||||
html = (
|
html = (
|
||||||
f'<font color="#14b8a6"><strong>🧩 Riddle!</strong></font><br>'
|
f'<font color="#14b8a6"><strong>🧩 Riddle!</strong></font><br>'
|
||||||
f'<blockquote>{riddle}</blockquote>'
|
f'<blockquote>{riddle}</blockquote>'
|
||||||
f'<em>Type your answer in chat — 60 seconds on the clock!</em>'
|
f'<em>Type your answer in chat — 60 seconds on the clock!</em><br>'
|
||||||
|
f'<sup><em>via {_model_label(BALL_MODEL)}</em></sup>'
|
||||||
)
|
)
|
||||||
await send_html(client, room_id, plain, html)
|
await send_html(client, room_id, plain, html)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user