Skip to content

Commit e7f9d3e

Browse files
author
ochafik
committed
fix test_chat_completion_with_timings_per_token & test_logprobs_stream
1 parent f026cb0 commit e7f9d3e

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

examples/server/tests/unit/test_chat_completion.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,11 @@ def test_chat_completion_with_timings_per_token():
242242
"stream": True,
243243
"timings_per_token": True,
244244
})
245-
for data in res:
245+
246+
for i, data in enumerate(res):
247+
if i == 0:
248+
assert "timings" not in data, f'First event should not have timings: {data}'
249+
continue
246250
assert "prompt_per_second" in data["timings"]
247251
assert "predicted_per_second" in data["timings"]
248252
assert "predicted_n" in data["timings"]
@@ -294,8 +298,15 @@ def test_logprobs_stream():
294298
)
295299
output_text = ''
296300
aggregated_text = ''
297-
for data in res:
301+
302+
for i, data in enumerate(res):
303+
assert len(data.choices) == 1
298304
choice = data.choices[0]
305+
306+
if i == 0:
307+
assert choice.delta.content is None
308+
continue
309+
299310
if choice.finish_reason is None:
300311
if choice.delta.content:
301312
output_text += choice.delta.content

0 commit comments

Comments
 (0)