File tree Expand file tree Collapse file tree 1 file changed +3
-4
lines changed Expand file tree Collapse file tree 1 file changed +3
-4
lines changed Original file line number Diff line number Diff line change @@ -332,8 +332,7 @@ async def completion_stream_generator() -> AsyncGenerator[str, None]:
332
332
# Send token-by-token response for each request.n
333
333
delta_text = output .text [len (previous_texts [i ]):]
334
334
previous_texts [i ] = output .text
335
- completion_tokens = len (output .token_ids )
336
- previous_num_tokens [i ] = completion_tokens
335
+ previous_num_tokens [i ] = len (output .token_ids )
337
336
choice_data = ChatCompletionResponseStreamChoice (
338
337
index = i ,
339
338
delta = DeltaMessage (content = delta_text ),
@@ -351,8 +350,8 @@ async def completion_stream_generator() -> AsyncGenerator[str, None]:
351
350
prompt_tokens = len (res .prompt_token_ids )
352
351
final_usage = UsageInfo (
353
352
prompt_tokens = prompt_tokens ,
354
- completion_tokens = completion_tokens ,
355
- total_tokens = prompt_tokens + completion_tokens ,
353
+ completion_tokens = previous_num_tokens [ i ] ,
354
+ total_tokens = prompt_tokens + previous_num_tokens [ i ] ,
356
355
)
357
356
choice_data = ChatCompletionResponseStreamChoice (
358
357
index = i , delta = [], finish_reason = output .finish_reason )
You can’t perform that action at this time.
0 commit comments