Skip to content

Commit 9726ad6

Browse files
authored
[Misc] Fix OpenAI API Compatibility Issues in Benchmark Script (#12357)
Signed-off-by: Junichi Sato <[email protected]>
1 parent eb5cb5e commit 9726ad6

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

benchmarks/backend_request_func.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -245,11 +245,12 @@ async def async_request_openai_completions(
245245
"max_tokens": request_func_input.output_len,
246246
"logprobs": request_func_input.logprobs,
247247
"stream": True,
248-
"ignore_eos": request_func_input.ignore_eos,
249248
"stream_options": {
250249
"include_usage": True,
251250
},
252251
}
252+
if request_func_input.ignore_eos:
253+
payload["ignore_eos"] = request_func_input.ignore_eos
253254
if request_func_input.extra_body:
254255
payload.update(request_func_input.extra_body)
255256
headers = {
@@ -297,7 +298,7 @@ async def async_request_openai_completions(
297298
most_recent_timestamp)
298299

299300
most_recent_timestamp = timestamp
300-
generated_text += text
301+
generated_text += text or ""
301302
elif usage := data.get("usage"):
302303
output.output_tokens = usage.get(
303304
"completion_tokens")
@@ -348,11 +349,12 @@ async def async_request_openai_chat_completions(
348349
"temperature": 0.0,
349350
"max_completion_tokens": request_func_input.output_len,
350351
"stream": True,
351-
"ignore_eos": request_func_input.ignore_eos,
352352
"stream_options": {
353353
"include_usage": True,
354354
},
355355
}
356+
if request_func_input.ignore_eos:
357+
payload["ignore_eos"] = request_func_input.ignore_eos
356358
if request_func_input.extra_body:
357359
payload.update(request_func_input.extra_body)
358360
headers = {
@@ -394,7 +396,7 @@ async def async_request_openai_chat_completions(
394396
output.itl.append(timestamp -
395397
most_recent_timestamp)
396398

397-
generated_text += content
399+
generated_text += content or ""
398400
elif usage := data.get("usage"):
399401
output.output_tokens = usage.get(
400402
"completion_tokens")

0 commit comments

Comments
 (0)