Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenDAS
vllm_cscc
Commits
cc935fdd
Unverified
Commit
cc935fdd
authored
Sep 18, 2025
by
Chauncey
Committed by
GitHub
Sep 18, 2025
Browse files
[Frontend] Support setting logprobs to -1 (#25031)
Signed-off-by:
chaunceyjiang
<
chaunceyjiang@gmail.com
>
parent
abdfcd4f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
3 deletions
+28
-3
tests/entrypoints/openai/test_chat_echo.py
tests/entrypoints/openai/test_chat_echo.py
+23
-0
vllm/entrypoints/openai/protocol.py
vllm/entrypoints/openai/protocol.py
+5
-3
No files found.
tests/entrypoints/openai/test_chat_echo.py
View file @
cc935fdd
...
...
@@ -99,3 +99,26 @@ async def test_prompt_logprobs(client: openai.AsyncOpenAI):
assert
completion
.
prompt_logprobs
is
not
None
assert
len
(
completion
.
prompt_logprobs
)
>
0
@
pytest
.
mark
.
asyncio
async
def
test_top_logprobs
(
client
:
openai
.
AsyncOpenAI
):
messages
=
[{
"role"
:
"system"
,
"content"
:
"You are a helpful assistant."
},
{
"role"
:
"user"
,
"content"
:
"Beijing is the capital of which country?"
}]
completion
=
await
client
.
chat
.
completions
.
create
(
model
=
MODEL_NAME
,
messages
=
messages
,
extra_body
=
{
"top_logprobs"
:
-
1
,
"logprobs"
:
"true"
,
},
)
assert
completion
.
choices
[
0
].
logprobs
is
not
None
assert
completion
.
choices
[
0
].
logprobs
.
content
is
not
None
assert
len
(
completion
.
choices
[
0
].
logprobs
.
content
)
>
0
vllm/entrypoints/openai/protocol.py
View file @
cc935fdd
...
...
@@ -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."
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment