mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-09 03:18:44 +00:00
fix(core): map Anthropic 'refusal' finish reason to 'content_filter'
Anthropic's 'refusal' stop_reason was missing from _FINISH_REASON_MAP, causing it to fall through to the default 'stop' — hiding the fact that the model refused to respond due to safety policies. Fixes #23793
This commit is contained in:
parent
2405e0d400
commit
8b4a74a69c
2 changed files with 4 additions and 0 deletions
|
|
@ -64,6 +64,7 @@ _FINISH_REASON_MAP: dict[str, OpenAIChatCompletionFinishReason] = {
|
|||
"end_turn": "stop",
|
||||
"max_tokens": "length",
|
||||
"tool_use": "tool_calls",
|
||||
"refusal": "content_filter",
|
||||
"compaction": "length",
|
||||
# Cohere
|
||||
"COMPLETE": "stop",
|
||||
|
|
|
|||
|
|
@ -74,6 +74,9 @@ class TestMapFinishReasonAnthropic:
|
|||
def test_compaction(self):
|
||||
assert map_finish_reason("compaction") == "length"
|
||||
|
||||
def test_refusal(self):
|
||||
assert map_finish_reason("refusal") == "content_filter"
|
||||
|
||||
|
||||
class TestMapFinishReasonGemini:
|
||||
@pytest.mark.parametrize(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue