File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed
Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -2339,6 +2339,8 @@ def test_cached_token_usage():
23392339 config = {"callbacks" : [handler ]}
23402340
23412341 chain .invoke ({"test_param" : "in a funny way" }, config )
2342+ chain .invoke ({"test_param" : "in a funny way" }, config )
2343+ sleep (1 )
23422344
23432345 # invoke again to force cached token usage
23442346 chain .invoke ({"test_param" : "in a funny way" }, config )
@@ -2359,8 +2361,11 @@ def test_cached_token_usage():
23592361
23602362 assert generation .cost_details ["input_cache_read" ] > 0
23612363 assert (
2362- generation .cost_details ["input" ]
2363- + generation .cost_details ["input_cache_read" ]
2364- + generation .cost_details ["output" ]
2365- == generation .cost_details ["total" ]
2364+ abs (
2365+ generation .cost_details ["input" ]
2366+ + generation .cost_details ["input_cache_read" ]
2367+ + generation .cost_details ["output" ]
2368+ - generation .cost_details ["total" ]
2369+ )
2370+ < 0.0001
23662371 )
You can’t perform that action at this time.
0 commit comments