Skip to content

Commit

Permalink
run formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
Yehoshua Cohen committed Jul 23, 2024
1 parent f78a2e3 commit 49294b8
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions vllm/entrypoints/openai/serving_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,13 +223,15 @@ async def chat_completion_stream_generator(
if (request.stream_options
and request.stream_options.include_usage):
if (request.stream_options.continuous_usage_stats
or output.finish_reason is not None):
or res.outputs[i].finish_reason
is not None):
prompt_tokens = len(res.prompt_token_ids)
completion_tokens = 0
usage = UsageInfo(
prompt_tokens=prompt_tokens,
completion_tokens=completion_tokens,
total_tokens=prompt_tokens + completion_tokens,
total_tokens=prompt_tokens +
completion_tokens,
)
if request.stream_options.continuous_usage_stats:
chunk.usage = usage
Expand Down Expand Up @@ -265,16 +267,22 @@ async def chat_completion_stream_generator(
model=model_name)
if (request.stream_options and
request.stream_options.include_usage):
if (request.stream_options.continuous_usage_stats
or output.finish_reason is not None):
prompt_tokens = len(res.prompt_token_ids)
completion_tokens = len(res.outputs[i].token_ids)
if (request.stream_options.
continuous_usage_stats
or res.outputs[i].finish_reason
is not None):
prompt_tokens = len(
res.prompt_token_ids)
completion_tokens = len(
res.outputs[i].token_ids)
usage = UsageInfo(
prompt_tokens=prompt_tokens,
completion_tokens=completion_tokens,
total_tokens=prompt_tokens + completion_tokens,
total_tokens=prompt_tokens +
completion_tokens,
)
if request.stream_options.continuous_usage_stats:
if (request.stream_options.
continuous_usage_stats):
chunk.usage = usage
else:
chunk.usage = None
Expand Down Expand Up @@ -343,7 +351,8 @@ async def chat_completion_stream_generator(
usage = UsageInfo(
prompt_tokens=prompt_tokens,
completion_tokens=completion_tokens,
total_tokens=prompt_tokens + completion_tokens,
total_tokens=prompt_tokens +
completion_tokens,
)
if request.stream_options.continuous_usage_stats:
chunk.usage = usage
Expand Down Expand Up @@ -375,7 +384,8 @@ async def chat_completion_stream_generator(
usage = UsageInfo(
prompt_tokens=prompt_tokens,
completion_tokens=completion_tokens,
total_tokens=prompt_tokens + completion_tokens,
total_tokens=prompt_tokens +
completion_tokens,
)
if request.stream_options.continuous_usage_stats:
chunk.usage = usage
Expand Down

0 comments on commit 49294b8

Please sign in to comment.