Skip to content

Commit 1ac7f87

Browse files
committed
fix test
1 parent e334f48 commit 1ac7f87

File tree

2 files changed

+31
-14
lines changed

2 files changed

+31
-14
lines changed

litellm/llms/anthropic/chat/handler.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -743,8 +743,6 @@ def chunk_parser(self, chunk: dict) -> ModelResponseStream:
743743
)
744744

745745
text, tool_use = self._handle_json_mode_chunk(text=text, tool_use=tool_use)
746-
if type_chunk:
747-
provider_specific_fields["chunk_type"] = type_chunk
748746

749747
returned_chunk = ModelResponseStream(
750748
choices=[

tests/test_litellm/llms/anthropic/chat/test_anthropic_chat_transformation.py

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -115,27 +115,23 @@ def test_calculate_usage_nulls(usage_object, expected_usage):
115115
assert hasattr(usage, k)
116116
assert getattr(usage, k) == v
117117

118-
@pytest.mark.parametrize("usage_object", [
119-
{
120-
"server_tool_use": {
121-
"web_search_requests": None
122-
}
123-
},
124-
{
125-
"server_tool_use": None
126-
}
127-
])
118+
119+
@pytest.mark.parametrize(
120+
"usage_object",
121+
[{"server_tool_use": {"web_search_requests": None}}, {"server_tool_use": None}],
122+
)
128123
def test_calculate_usage_server_tool_null(usage_object):
129124
"""
130125
Correctly deal with null values in usage object
131126
132127
Fixes https://github.com/BerriAI/litellm/issues/11920
133128
"""
134129
config = AnthropicConfig()
135-
130+
136131
usage = config.calculate_usage(usage_object=usage_object, reasoning_content=None)
137132
assert not hasattr(usage, "server_tool_use")
138133

134+
139135
def test_extract_response_content_with_citations():
140136
config = AnthropicConfig()
141137

@@ -188,7 +184,30 @@ def test_extract_response_content_with_citations():
188184
}
189185

190186
_, citations, _, _, _ = config.extract_response_content(completion_response)
191-
assert citations is not None
187+
assert citations == [
188+
[
189+
{
190+
"type": "char_location",
191+
"cited_text": "The grass is green. ",
192+
"document_index": 0,
193+
"document_title": "My Document",
194+
"start_char_index": 0,
195+
"end_char_index": 20,
196+
"supported_text": "the grass is green",
197+
},
198+
],
199+
[
200+
{
201+
"type": "char_location",
202+
"cited_text": "The sky is blue.",
203+
"document_index": 0,
204+
"document_title": "My Document",
205+
"start_char_index": 20,
206+
"end_char_index": 36,
207+
"supported_text": "the sky is blue",
208+
},
209+
],
210+
]
192211

193212

194213
def test_map_tool_helper():

0 commit comments

Comments
 (0)