The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
fix(core): map Anthropic 'refusal' finish reason to 'content_filter'
Chesars8b4a74a69c14
diff --git a/litellm/litellm_core_utils/core_helpers.py b/litellm/litellm_core_utils/core_helpers.pyindex ee111f35929..9d9255cdf15 100644--- a/litellm/litellm_core_utils/core_helpers.py+++ b/litellm/litellm_core_utils/core_helpers.py@@ -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",diff --git a/tests/test_litellm/litellm_core_utils/test_core_helpers.py b/tests/test_litellm/litellm_core_utils/test_core_helpers.pyindex 0ef76e0942d..134ed5d25f8 100644--- a/tests/test_litellm/litellm_core_utils/test_core_helpers.py+++ b/tests/test_litellm/litellm_core_utils/test_core_helpers.py@@ -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(