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
Merge pull request #23899 from Chesars/fix/map-anthropic-refusal-finish-reason
Cesar Garciac1db67ab6750
diff --cc tests/test_litellm/litellm_core_utils/test_core_helpers.pyindex 72c3b2b077e,134ed5d25f8..8397fc22242--- a/tests/test_litellm/litellm_core_utils/test_core_helpers.py+++ b/tests/test_litellm/litellm_core_utils/test_core_helpers.py@@@ -59,20 -59,24 +59,23 @@@ VALID_OPENAI_FINISH_REASONS = {"stop",class TestMapFinishReasonAnthropic:- def test_stop_sequence(self):- assert map_finish_reason("stop_sequence") == "stop"-- def test_end_turn(self):- assert map_finish_reason("end_turn") == "stop"-- def test_max_tokens(self):- assert map_finish_reason("max_tokens") == "length"-- def test_tool_use(self):- assert map_finish_reason("tool_use") == "tool_calls"-- def test_compaction(self):- assert map_finish_reason("compaction") == "length"+ @pytest.mark.parametrize(+ "provider_reason,expected",+ [+ ("stop_sequence", "stop"),+ ("end_turn", "stop"),+ ("max_tokens", "length"),+ ("tool_use", "tool_calls"),+ ("compaction", "length"),+ ("content_filtered", "content_filter"),+ ],+ )+ def test_anthropic_finish_reasons(self, provider_reason: str, expected: str) -> None:+ assert map_finish_reason(provider_reason) == expected+ def test_refusal(self):+ assert map_finish_reason("refusal") == "content_filter"+class TestMapFinishReasonGemini:@pytest.mark.parametrize(