Skip to content

Commit ccb58b2

Browse files
authored
[Misc] Fix Benchmark TTFT Calculation for Chat Completions (#3768)
1 parent 49782fc commit ccb58b2

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

benchmarks/backend_request_func.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,8 @@ async def async_request_openai_chat_completions(
334334
timestamp = time.perf_counter()
335335
data = json.loads(chunk)
336336

337-
if "content" in data["choices"][0]["delta"]:
337+
delta = data["choices"][0]["delta"]
338+
if delta.get("content", None):
338339
# First token
339340
if ttft == 0:
340341
ttft = time.perf_counter() - st
@@ -345,8 +346,7 @@ async def async_request_openai_chat_completions(
345346
output.itl.append(timestamp -
346347
most_recent_timestamp)
347348

348-
generated_text += data["choices"][0]["delta"][
349-
"content"]
349+
generated_text += delta["content"]
350350

351351
most_recent_timestamp = timestamp
352352

0 commit comments

Comments
 (0)