@@ -248,7 +248,7 @@ def process_delta(new_delta: DeltaMessage, message_completion: GenerationMessage
248
248
if new_delta .tool_calls :
249
249
if "tool_calls" not in message_completion :
250
250
message_completion ["tool_calls" ] = []
251
- delta_tool_call = new_delta .tool_calls [0 ]
251
+ delta_tool_call = new_delta .tool_calls [0 ] # type: ignore
252
252
delta_function = delta_tool_call .function
253
253
if not delta_function :
254
254
return False
@@ -303,22 +303,22 @@ def streaming_response(
303
303
token_count += 1
304
304
elif generation and isinstance (generation , CompletionGeneration ):
305
305
if (
306
- len (chunk .choices ) > 0
307
- and chunk .choices [0 ].message .content is not None
306
+ len (chunk .data . choices ) > 0
307
+ and chunk .data . choices [0 ].delta .content is not None
308
308
):
309
309
if generation .tt_first_token is None :
310
310
generation .tt_first_token = (
311
311
time .time () - context ["start" ]
312
312
) * 1000
313
313
token_count += 1
314
- completion += chunk .choices [0 ].message .content
314
+ completion += chunk .data . choices [0 ].delta .content
315
315
316
316
if (
317
317
generation
318
318
and getattr (chunk , "model" , None )
319
- and generation .model != chunk .model
319
+ and generation .model != chunk .data . model
320
320
):
321
- generation .model = chunk .model
321
+ generation .model = chunk .data . model
322
322
323
323
yield chunk
324
324
@@ -415,22 +415,22 @@ async def async_streaming_response(
415
415
token_count += 1
416
416
elif generation and isinstance (generation , CompletionGeneration ):
417
417
if (
418
- len (chunk .choices ) > 0
419
- and chunk .choices [0 ].message . content is not None
418
+ len (chunk .data . choices ) > 0
419
+ and chunk .data . choices [0 ].delta is not None
420
420
):
421
421
if generation .tt_first_token is None :
422
422
generation .tt_first_token = (
423
423
time .time () - context ["start" ]
424
424
) * 1000
425
425
token_count += 1
426
- completion += chunk .choices [0 ].message .content
426
+ completion += chunk .data . choices [0 ].delta .content or ""
427
427
428
428
if (
429
429
generation
430
430
and getattr (chunk , "model" , None )
431
- and generation .model != chunk .model
431
+ and generation .model != chunk .data . model
432
432
):
433
- generation .model = chunk .model
433
+ generation .model = chunk .data . model
434
434
435
435
yield chunk
436
436
0 commit comments