@@ -109,26 +109,30 @@ def test_langfuse_usage_details_type(self):
109
109
usage_details : LangfuseUsageDetails = {
110
110
"input" : 10 ,
111
111
"output" : 20 ,
112
+ "total" : 30 ,
112
113
"cache_creation_input_tokens" : 5 ,
113
114
"cache_read_input_tokens" : 3
114
115
}
115
116
116
117
# Verify all fields are present
117
118
self .assertEqual (usage_details ["input" ], 10 )
118
119
self .assertEqual (usage_details ["output" ], 20 )
120
+ self .assertEqual (usage_details ["total" ], 30 )
119
121
self .assertEqual (usage_details ["cache_creation_input_tokens" ], 5 )
120
122
self .assertEqual (usage_details ["cache_read_input_tokens" ], 3 )
121
123
122
124
# Test with all fields (all fields are required in TypedDict by default)
123
125
minimal_usage_details : LangfuseUsageDetails = {
124
126
"input" : 10 ,
125
127
"output" : 20 ,
128
+ "total" : 30 ,
126
129
"cache_creation_input_tokens" : 0 ,
127
130
"cache_read_input_tokens" : 0
128
131
}
129
132
130
133
self .assertEqual (minimal_usage_details ["input" ], 10 )
131
134
self .assertEqual (minimal_usage_details ["output" ], 20 )
135
+ self .assertEqual (minimal_usage_details ["total" ], 30 )
132
136
133
137
def test_log_langfuse_v2_usage_details (self ):
134
138
"""Test that usage_details in _log_langfuse_v2 is correctly typed and assigned"""
@@ -183,13 +187,15 @@ def test_langfuse_usage_details_optional_fields(self):
183
187
usage_details : LangfuseUsageDetails = {
184
188
"input" : 10 ,
185
189
"output" : 20 ,
190
+ "total" : 30 ,
186
191
"cache_creation_input_tokens" : None ,
187
192
"cache_read_input_tokens" : None
188
193
}
189
194
190
195
# Verify fields can be None
191
196
self .assertEqual (usage_details ["input" ], 10 )
192
197
self .assertEqual (usage_details ["output" ], 20 )
198
+ self .assertEqual (usage_details ["total" ], 30 )
193
199
self .assertIsNone (usage_details ["cache_creation_input_tokens" ])
194
200
self .assertIsNone (usage_details ["cache_read_input_tokens" ])
195
201
@@ -202,19 +208,22 @@ def test_langfuse_usage_details_structure(self):
202
208
usage_details = {
203
209
"input" : 15 ,
204
210
"output" : 25 ,
211
+ "total" : 40 ,
205
212
"cache_creation_input_tokens" : 7 ,
206
213
"cache_read_input_tokens" : 4
207
214
}
208
215
209
216
# Verify the structure matches what we expect
210
217
self .assertIn ("input" , usage_details )
211
218
self .assertIn ("output" , usage_details )
219
+ self .assertIn ("total" , usage_details )
212
220
self .assertIn ("cache_creation_input_tokens" , usage_details )
213
221
self .assertIn ("cache_read_input_tokens" , usage_details )
214
222
215
223
# Verify the values
216
224
self .assertEqual (usage_details ["input" ], 15 )
217
225
self .assertEqual (usage_details ["output" ], 25 )
226
+ self .assertEqual (usage_details ["total" ], 40 )
218
227
self .assertEqual (usage_details ["cache_creation_input_tokens" ], 7 )
219
228
self .assertEqual (usage_details ["cache_read_input_tokens" ], 4 )
220
229
0 commit comments