Skip to content

Commit ee09046

Browse files
committed
create static method to clean prompt_logprobs
Signed-off-by: maxDavid40 <maxdavid40@gmail.com>
1 parent bffb799 commit ee09046

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

vllm/entrypoints/openai/serving_engine.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,20 @@ async def _get_trace_headers(
499499

500500
return None
501501

502+
@staticmethod
503+
def _clean_prompt_logprobs(
504+
prompt_logprobs: Union[None, List[Union[None, Dict]]]) -> None:
505+
"""
506+
Preprocess prompt_logprobs result
507+
to avoid starlette.response.JSONResponse's error
508+
"""
509+
if prompt_logprobs:
510+
for logprob_dict in prompt_logprobs:
511+
if logprob_dict:
512+
for logprob_values in logprob_dict.values():
513+
if logprob_values.logprob == float('-inf'):
514+
logprob_values.logprob = -9999.0
515+
502516
@staticmethod
503517
def _base_request_id(raw_request: Optional[Request],
504518
default: Optional[str] = None) -> Optional[str]:

0 commit comments

Comments
 (0)