@@ -157,15 +157,20 @@ def _save_routing_lines(
157
157
)
158
158
return False
159
159
160
- def send_request (self , request_id : str , prompt : str ) -> bool :
160
+ def send_request (
161
+ self , request_id : str , prompt : str , custom_payload : dict = None
162
+ ) -> bool :
161
163
"""Send a single request and track which endpoint it goes to"""
162
164
try :
163
- payload = {
164
- "model" : self .model ,
165
- "prompt" : prompt ,
166
- "temperature" : 0.7 ,
167
- "max_tokens" : 10 ,
168
- }
165
+ if custom_payload is not None :
166
+ payload = custom_payload
167
+ else :
168
+ payload = {
169
+ "model" : self .model ,
170
+ "prompt" : prompt ,
171
+ "temperature" : 0.7 ,
172
+ "max_tokens" : 10 ,
173
+ }
169
174
170
175
headers = {
171
176
"Content-Type" : "application/json" ,
@@ -542,6 +547,43 @@ def test_chat_completions(self) -> bool:
542
547
print_error (f"❌ Chat completions failed: { e } payload: { payload } " )
543
548
return False
544
549
550
+ def test_drop_params (self ) -> bool :
551
+ """Test that the router drops specified parameters from requests"""
552
+ print_status ("🧪 Testing drop_params functionality" )
553
+
554
+ # Send a request with parameters that should be dropped
555
+ try :
556
+ # Use the existing send_request method with custom payload to test drop_params
557
+ custom_payload = {
558
+ "model" : self .model ,
559
+ "prompt" : "Test prompt with parameters to drop" ,
560
+ "temperature" : 0.7 ,
561
+ "max_tokens" : 10 ,
562
+ "test-param-to-drop" : 0.5 , # This should be dropped
563
+ }
564
+
565
+ # Send request using existing method with custom payload
566
+ if not self .send_request (
567
+ "test-drop-params-request" ,
568
+ "Test prompt with parameters to drop" ,
569
+ custom_payload ,
570
+ ):
571
+ print_error ("❌ Drop params test request failed" )
572
+ return False
573
+
574
+ # Check router logs for evidence that parameters were dropped
575
+ content = self ._read_log_file ()
576
+ if content is not None :
577
+ if "Dropped param test-param-to-drop from request" in str (content ):
578
+ print_status ("✅ Drop params test request completed successfully" )
579
+ return True
580
+
581
+ print_error ("❌ Drop params test request failed" )
582
+ return False
583
+ except Exception as e :
584
+ print_error (f"❌ Unexpected error in drop params test: { e } " )
585
+ return False
586
+
545
587
def run_test (self ) -> bool :
546
588
"""Run the complete routing test"""
547
589
try :
@@ -559,6 +601,10 @@ def run_test(self) -> bool:
559
601
if not self .test_chat_completions ():
560
602
return False
561
603
604
+ # Test drop_params functionality
605
+ if not self .test_drop_params ():
606
+ return False
607
+
562
608
# Test routing logic
563
609
test_runners = {
564
610
"roundrobin" : self .test_roundrobin_routing ,
0 commit comments