[Frontend] Support setting logprobs to -1 (#25031)

Signed-off-by: chaunceyjiang <chaunceyjiang@gmail.com>
This commit is contained in:
Chauncey
2025-09-18 10:34:42 +00:00
committed by GitHub
parent abdfcd4f3d
commit cc935fdd7e
2 changed files with 28 additions and 3 deletions
+5 -3
View File
@@ -832,10 +832,12 @@ class ChatCompletionRequest(OpenAIBaseModel):
raise ValueError("`prompt_logprobs=-1` is only supported with "
"vLLM engine V1.")
if (top_logprobs := data.get("top_logprobs")) is not None:
if top_logprobs < 0:
raise ValueError("`top_logprobs` must be a positive value.")
if top_logprobs < 0 and top_logprobs != -1:
raise ValueError(
"`top_logprobs` must be a positive value or -1.")
if top_logprobs > 0 and not data.get("logprobs"):
if (top_logprobs == -1
or top_logprobs > 0) and not data.get("logprobs"):
raise ValueError(
"when using `top_logprobs`, `logprobs` must be set to true."
)