@@ -101,10 +101,14 @@ def make_request(
101101 try :
102102 # If files are provided, don't send JSON body
103103 if files :
104+ # Remove Content-Type header for file uploads (requests will set it automatically)
105+ filtered_headers = {
106+ k : v for k , v in headers .items () if k != "Content-Type"
107+ }
104108 response = requests .request (
105109 method = method ,
106110 url = url ,
107- headers = { k : v for k , v in headers . items () if k != "Content-Type" } ,
111+ headers = filtered_headers ,
108112 files = files ,
109113 stream = stream ,
110114 )
@@ -275,25 +279,28 @@ def send(
275279 thread_id = response .headers .get ("lb-thread-id" )
276280
277281 if not body :
282+ raw_response = body .get ("raw_response" , False ) if body else False
278283 return self .handle_run_response (
279284 response ,
280285 thread_id = None ,
281- raw_response = body . get ( " raw_response" , False ) if body else False ,
286+ raw_response = raw_response ,
282287 endpoint = endpoint ,
283288 )
284289
285290 if body .get ("stream" ) and "run" in url :
291+ raw_response = body .get ("raw_response" , False )
286292 return self .handle_run_response_stream (
287- response , raw_response = body . get ( " raw_response" , False )
293+ response , raw_response = raw_response
288294 )
289295
290296 if body .get ("stream" ):
291297 return self .handle_stream_response (response )
292298
299+ raw_response = body .get ("raw_response" , False )
293300 return self .handle_run_response (
294301 response ,
295302 thread_id = thread_id ,
296- raw_response = body . get ( " raw_response" , False ) ,
303+ raw_response = raw_response ,
297304 endpoint = endpoint ,
298305 )
299306 # For non-generation endpoints, just return the JSON response
0 commit comments