Skip to content

Commit 30db3e9

Browse files
authored
[benchmark] update tools (#7512)
1 parent c9783a8 commit 30db3e9

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

benchmarks/backend_request_func.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,15 @@ async def async_request_eb_openai_chat_completions(
428428
# output.generated_text = generated_text
429429
# 在流式结束时,记录最后一个 chunk 收到的时间戳
430430
output.end_timestamp = most_recent_timestamp
431+
# 截断case也记录usage
432+
usage = data.get("usage", {})
433+
if usage:
434+
output.output_tokens = usage.get("completion_tokens", 0)
435+
output.prompt_tokens = usage.get("prompt_tokens", 0)
436+
if output.prompt_len == 0:
437+
prompt_details = usage.get("prompt_tokens_details", {})
438+
if prompt_details:
439+
output.prompt_len = prompt_details.get("cached_tokens", 0)
431440

432441
if tool_call_buffer:
433442
for _, tc in tool_call_buffer.items():

0 commit comments

Comments
 (0)