@@ -115,27 +115,23 @@ def test_calculate_usage_nulls(usage_object, expected_usage):
115
115
assert hasattr (usage , k )
116
116
assert getattr (usage , k ) == v
117
117
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
+ )
128
123
def test_calculate_usage_server_tool_null (usage_object ):
129
124
"""
130
125
Correctly deal with null values in usage object
131
126
132
127
Fixes https://github.com/BerriAI/litellm/issues/11920
133
128
"""
134
129
config = AnthropicConfig ()
135
-
130
+
136
131
usage = config .calculate_usage (usage_object = usage_object , reasoning_content = None )
137
132
assert not hasattr (usage , "server_tool_use" )
138
133
134
+
139
135
def test_extract_response_content_with_citations ():
140
136
config = AnthropicConfig ()
141
137
@@ -188,7 +184,30 @@ def test_extract_response_content_with_citations():
188
184
}
189
185
190
186
_ , 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
+ ]
192
211
193
212
194
213
def test_map_tool_helper ():
0 commit comments