fix(llm): catch bare "cannot generate" phrasing without a leading "I"
The lexical refusal pattern required an "I" before cannot/can't/won't so a refusal fragment like "Cannot generate this image due to the content" (no leading pronoun — the shape it takes as a JSON string value or a mid-sentence fragment) went undetected. Made the "I" prefix optional; the cannot/can't/won't-plus-nearby-generate/create/ etc. shape is specific enough that dropping the pronoun requirement doesn't pick up ordinary content (verified against the existing "ordinary content" regression cases). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
3c5136af70
commit
a0f391f212
@@ -60,7 +60,7 @@ def next_seed(options: dict | None, attempt: int) -> int:
|
||||
REFUSAL_LEXICAL_PATTERNS: tuple[re.Pattern, ...] = tuple(
|
||||
re.compile(p, re.IGNORECASE)
|
||||
for p in (
|
||||
r"\bI\s*(?:'m|\s+am)?\s*(?:cannot|can't|won't|will not)\b[^.]{0,60}?\b"
|
||||
r"\b(?:I\s*(?:'m|\s+am)?\s*)?(?:cannot|can't|won't|will not)\b[^.]{0,60}?\b"
|
||||
r"(?:generate|create|produce|write|provide|help|assist|describe|depict|continue)\b",
|
||||
r"\bI(?:'m|\s+am) (?:not able|unable) to\b",
|
||||
r"\bI don't feel comfortable\b",
|
||||
|
||||
@@ -51,6 +51,8 @@ class TestLexicalDetection:
|
||||
"I cannot generate that image for you.",
|
||||
"I'm not able to help with this request.",
|
||||
"I am unable to comply with your instruction.",
|
||||
"Cannot generate this image due to the sensitive content.",
|
||||
'{"error": "cannot generate this content"}',
|
||||
"I don't feel comfortable creating this content.",
|
||||
"I'm sorry, but I can't produce that description.",
|
||||
"As an AI, I'm unable to depict this scenario.",
|
||||
|
||||
Reference in New Issue
Block a user