Expand description
Heuristic refusal classifier.
Populates message.refusal on the blocking chat-completion path so
safety-aware clients (OpenAI Python SDK, Vercel AI SDK) that branch on
message.refusal != null see the expected shape. Atlas does not
train safety behavior into its models — this detector only recognizes
the text the underlying model emits when it declines to answer.
Honest scope: a prefix-matcher, not a safety classifier. It catches the
common refusal openings (“I cannot help with…”, “I’m sorry, but I
can’t…”, “As an AI…”) that instruction-tuned models produce. It will
miss subtle refusals and will false-positive on content that quotes a
refusal. Clients that need real safety-classification should run their
own moderation pass — /v1/moderations is a 501 stub on this server.
Set ATLAS_DISABLE_REFUSAL_DETECTION=1 to force refusal: None on all
responses, matching pre-PR-4 behavior byte-for-byte.
Functions§
- detect
- Returns the refusal sentence when
contentopens with one of the known patterns, elseNone. The returned sentence is the first sentence (truncated at.,?, or!) with trailing whitespace trimmed. When the kill-switch env var is set, always returnsNone.