@@ -2608,3 +2608,64 @@ def test_caching_with_reasoning_content():
2608
2608
print (f"response 2: { response_2 .model_dump_json (indent = 4 )} " )
2609
2609
assert response_2 ._hidden_params ["cache_hit" ] == True
2610
2610
assert response_2 .choices [0 ].message .reasoning_content is not None
2611
+
2612
+
2613
+ def test_caching_reasoning_args_miss (): # test in memory cache
2614
+ try :
2615
+ #litellm._turn_on_debug()
2616
+ litellm .set_verbose = True
2617
+ litellm .cache = Cache (
2618
+ )
2619
+ response1 = completion (model = "claude-3-7-sonnet-latest" , messages = messages , caching = True , reasoning_effort = "low" , mock_response = "My response" )
2620
+ response2 = completion (model = "claude-3-7-sonnet-latest" , messages = messages , caching = True , mock_response = "My response" )
2621
+ print (f"response1: { response1 } " )
2622
+ print (f"response2: { response2 } " )
2623
+ assert response1 .id != response2 .id
2624
+ except Exception as e :
2625
+ print (f"error occurred: { traceback .format_exc ()} " )
2626
+ pytest .fail (f"Error occurred: { e } " )
2627
+
2628
+ def test_caching_reasoning_args_hit (): # test in memory cache
2629
+ try :
2630
+ #litellm._turn_on_debug()
2631
+ litellm .set_verbose = True
2632
+ litellm .cache = Cache (
2633
+ )
2634
+ response1 = completion (model = "claude-3-7-sonnet-latest" , messages = messages , caching = True , reasoning_effort = "low" , mock_response = "My response" )
2635
+ response2 = completion (model = "claude-3-7-sonnet-latest" , messages = messages , caching = True , reasoning_effort = "low" , mock_response = "My response" )
2636
+ print (f"response1: { response1 } " )
2637
+ print (f"response2: { response2 } " )
2638
+ assert response1 .id == response2 .id
2639
+ except Exception as e :
2640
+ print (f"error occurred: { traceback .format_exc ()} " )
2641
+ pytest .fail (f"Error occurred: { e } " )
2642
+
2643
+ def test_caching_thinking_args_miss (): # test in memory cache
2644
+ try :
2645
+ #litellm._turn_on_debug()
2646
+ litellm .set_verbose = True
2647
+ litellm .cache = Cache (
2648
+ )
2649
+ response1 = completion (model = "claude-3-7-sonnet-latest" , messages = messages , caching = True , thinking = {"type" : "enabled" , "budget_tokens" : 1024 }, mock_response = "My response" )
2650
+ response2 = completion (model = "claude-3-7-sonnet-latest" , messages = messages , caching = True , mock_response = "My response" )
2651
+ print (f"response1: { response1 } " )
2652
+ print (f"response2: { response2 } " )
2653
+ assert response1 .id != response2 .id
2654
+ except Exception as e :
2655
+ print (f"error occurred: { traceback .format_exc ()} " )
2656
+ pytest .fail (f"Error occurred: { e } " )
2657
+
2658
+ def test_caching_thinking_args_hit (): # test in memory cache
2659
+ try :
2660
+ #litellm._turn_on_debug()
2661
+ litellm .set_verbose = True
2662
+ litellm .cache = Cache (
2663
+ )
2664
+ response1 = completion (model = "claude-3-7-sonnet-latest" , messages = messages , caching = True , thinking = {"type" : "enabled" , "budget_tokens" : 1024 }, mock_response = "My response" )
2665
+ response2 = completion (model = "claude-3-7-sonnet-latest" , messages = messages , caching = True , thinking = {"type" : "enabled" , "budget_tokens" : 1024 }, mock_response = "My response" )
2666
+ print (f"response1: { response1 } " )
2667
+ print (f"response2: { response2 } " )
2668
+ assert response1 .id == response2 .id
2669
+ except Exception as e :
2670
+ print (f"error occurred: { traceback .format_exc ()} " )
2671
+ pytest .fail (f"Error occurred: { e } " )
0 commit comments