Files
9router/open-sse/translator/schema/finishReasons.js
Welington 0f488c7027 fix(translator): map Claude "refusal" stop_reason to content_filter and surface its explanation
Anthropic's API-level refusal (streaming classifier / ToS) ends the stream
with stop_reason "refusal", stop_details carrying the reason, zero output
tokens and no content blocks. Map refusal to content_filter in both
directions, surface stop_details.explanation as message text, and add
CLAUDE_STOP.REFUSAL to schema.
2026-09-22 15:32:48 +07:00

31 lines
892 B
JavaScript

// Finish/stop reason enums. Pure data — mapping LOGIC lives in concerns/finishReason.js.
// OpenAI finish_reason values (the hub format; shared across all response translators).
export const OPENAI_FINISH = {
STOP: "stop",
LENGTH: "length",
TOOL_CALLS: "tool_calls",
CONTENT_FILTER: "content_filter",
};
// Claude stop_reason values.
export const CLAUDE_STOP = {
END_TURN: "end_turn",
MAX_TOKENS: "max_tokens",
TOOL_USE: "tool_use",
STOP_SEQUENCE: "stop_sequence",
// Anthropic's API-level refusal (streaming classifier / ToS). Arrives in
// message_delta with zero output tokens; stop_details carries the reason.
REFUSAL: "refusal",
};
// Gemini finishReason values.
export const GEMINI_FINISH = {
STOP: "STOP",
MAX_TOKENS: "MAX_TOKENS",
SAFETY: "SAFETY",
RECITATION: "RECITATION",
BLOCKLIST: "BLOCKLIST",
PROHIBITED_CONTENT: "PROHIBITED_CONTENT",
};