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 test
TomeHirata1ac7f875c9e2
diff --git a/litellm/llms/anthropic/chat/handler.py b/litellm/llms/anthropic/chat/handler.pyindex 253f5d9be2c..5618c50923e 100644--- a/litellm/llms/anthropic/chat/handler.py+++ b/litellm/llms/anthropic/chat/handler.py@@ -743,8 +743,6 @@ class ModelResponseIterator:)text, tool_use = self._handle_json_mode_chunk(text=text, tool_use=tool_use)- if type_chunk:- provider_specific_fields["chunk_type"] = type_chunkreturned_chunk = ModelResponseStream(choices=[diff --git a/tests/test_litellm/llms/anthropic/chat/test_anthropic_chat_transformation.py b/tests/test_litellm/llms/anthropic/chat/test_anthropic_chat_transformation.pyindex ff454968d9c..dcca87baf32 100644--- a/tests/test_litellm/llms/anthropic/chat/test_anthropic_chat_transformation.py+++ b/tests/test_litellm/llms/anthropic/chat/test_anthropic_chat_transformation.py@@ -115,16 +115,11 @@ def test_calculate_usage_nulls(usage_object, expected_usage):assert hasattr(usage, k)assert getattr(usage, k) == v[email protected]("usage_object", [- {- "server_tool_use": {- "web_search_requests": None- }- },- {- "server_tool_use": None- }-])++ "usage_object",+ [{"server_tool_use": {"web_search_requests": None}}, {"server_tool_use": None}],+)def test_calculate_usage_server_tool_null(usage_object):"""Correctly deal with null values in usage object@@ -132,10 +127,11 @@ def test_calculate_usage_server_tool_null(usage_object):Fixes https://github.com/BerriAI/litellm/issues/11920"""config = AnthropicConfig()-+usage = config.calculate_usage(usage_object=usage_object, reasoning_content=None)assert not hasattr(usage, "server_tool_use")+def test_extract_response_content_with_citations():config = AnthropicConfig()@@ -188,7 +184,30 @@ def test_extract_response_content_with_citations():}_, citations, _, _, _ = config.extract_response_content(completion_response)- assert citations is not None+ assert citations == [+ [+ {+ "type": "char_location",+ "cited_text": "The grass is green. ",+ "document_index": 0,+ "document_title": "My Document",+ "start_char_index": 0,+ "end_char_index": 20,+ "supported_text": "the grass is green",+ },+ ],+ [+ {+ "type": "char_location",+ "cited_text": "The sky is blue.",+ "document_index": 0,+ "document_title": "My Document",+ "start_char_index": 20,+ "end_char_index": 36,+ "supported_text": "the sky is blue",+ },+ ],+ ]def test_map_tool_helper():