File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1102,22 +1102,9 @@ def _flatten_comprehension(matrix: Any) -> Any:
11021102 return [item for row in matrix for item in row ]
11031103
11041104
1105- _TOKEN_DETAIL_SUBTRACT_KEYS = {
1106- "audio" ,
1107- "cache_read" ,
1108- "cache_creation" ,
1109- "reasoning" ,
1110- }
1111-
1112-
11131105def _should_subtract_token_detail (detail_key : str ) -> bool :
11141106 normalized_key = detail_key .lower ()
1115- for subtract_key in _TOKEN_DETAIL_SUBTRACT_KEYS :
1116- if normalized_key == subtract_key or normalized_key .endswith (
1117- f"_{ subtract_key } "
1118- ):
1119- return True
1120- return False
1107+ return not normalized_key .startswith ("priority" )
11211108
11221109
11231110def _parse_usage_model (usage : Union [pydantic .BaseModel , dict ]) -> Any :
Original file line number Diff line number Diff line change @@ -33,17 +33,21 @@ def test_parse_usage_model_subtracts_known_details():
3333 "input_token_details" : {
3434 "cache_read" : 20 ,
3535 "audio" : 5 ,
36+ "custom_detail" : 3 ,
3637 },
3738 "output_token_details" : {
3839 "reasoning" : 10 ,
40+ "custom_output" : 2 ,
3941 },
4042 }
4143
4244 parsed = _parse_usage_model (usage )
4345
44- assert parsed ["input" ] == 75
45- assert parsed ["output" ] == 40
46+ assert parsed ["input" ] == 72
47+ assert parsed ["output" ] == 38
4648 assert parsed ["input_cache_read" ] == 20
4749 assert parsed ["input_audio" ] == 5
50+ assert parsed ["input_custom_detail" ] == 3
4851 assert parsed ["output_reasoning" ] == 10
52+ assert parsed ["output_custom_output" ] == 2
4953 assert parsed ["total" ] == 150
You can’t perform that action at this time.
0 commit comments