Skip to content

Commit bc2c0c8

Browse files
authored
[Frontend] Fix usage incorrectly returned with empty stream_options` (vllm-project#36379)
Signed-off-by: Csrayz <33659823+Csrayz@users.noreply.github.com>
1 parent 891c60d commit bc2c0c8

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

tests/v1/entrypoints/openai/test_completion.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,18 @@ async def test_completion_stream_options(client: openai.AsyncOpenAI, model_name:
457457
)
458458
assert final_chunk.choices == []
459459

460+
# Test stream=True, stream_options={}
461+
stream = await client.completions.create(
462+
model=model_name,
463+
prompt=prompt,
464+
max_tokens=5,
465+
temperature=0.0,
466+
stream=True,
467+
stream_options={},
468+
)
469+
async for chunk in stream:
470+
assert chunk.usage is None
471+
460472
# Test stream=False, stream_options=
461473
# {"include_usage": None}
462474
with pytest.raises(BadRequestError):

vllm/entrypoints/openai/engine/protocol.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ class ResponseFormat(OpenAIBaseModel):
159159

160160

161161
class StreamOptions(OpenAIBaseModel):
162-
include_usage: bool | None = True
162+
include_usage: bool | None = False
163163
continuous_usage_stats: bool | None = False
164164

165165

0 commit comments

Comments
 (0)