@@ -101,10 +101,14 @@ def make_request(
101
101
try :
102
102
# If files are provided, don't send JSON body
103
103
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
+ }
104
108
response = requests .request (
105
109
method = method ,
106
110
url = url ,
107
- headers = { k : v for k , v in headers . items () if k != "Content-Type" } ,
111
+ headers = filtered_headers ,
108
112
files = files ,
109
113
stream = stream ,
110
114
)
@@ -275,25 +279,28 @@ def send(
275
279
thread_id = response .headers .get ("lb-thread-id" )
276
280
277
281
if not body :
282
+ raw_response = body .get ("raw_response" , False ) if body else False
278
283
return self .handle_run_response (
279
284
response ,
280
285
thread_id = None ,
281
- raw_response = body . get ( " raw_response" , False ) if body else False ,
286
+ raw_response = raw_response ,
282
287
endpoint = endpoint ,
283
288
)
284
289
285
290
if body .get ("stream" ) and "run" in url :
291
+ raw_response = body .get ("raw_response" , False )
286
292
return self .handle_run_response_stream (
287
- response , raw_response = body . get ( " raw_response" , False )
293
+ response , raw_response = raw_response
288
294
)
289
295
290
296
if body .get ("stream" ):
291
297
return self .handle_stream_response (response )
292
298
299
+ raw_response = body .get ("raw_response" , False )
293
300
return self .handle_run_response (
294
301
response ,
295
302
thread_id = thread_id ,
296
- raw_response = body . get ( " raw_response" , False ) ,
303
+ raw_response = raw_response ,
297
304
endpoint = endpoint ,
298
305
)
299
306
# For non-generation endpoints, just return the JSON response
0 commit comments