Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
change
sglang
Commits
05ee2192
Unverified
Commit
05ee2192
authored
Apr 28, 2025
by
Chang Su
Committed by
GitHub
Apr 28, 2025
Browse files
Support `max_completion_tokens` for OpenAIChatCompletions (#5857)
parent
dcae1fb2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
2 deletions
+11
-2
python/sglang/srt/openai_api/adapter.py
python/sglang/srt/openai_api/adapter.py
+1
-1
python/sglang/srt/openai_api/protocol.py
python/sglang/srt/openai_api/protocol.py
+10
-1
No files found.
python/sglang/srt/openai_api/adapter.py
View file @
05ee2192
...
...
@@ -1099,7 +1099,7 @@ def v1_chat_generate_request(
sampling_params
=
{
"temperature"
:
request
.
temperature
,
"max_new_tokens"
:
request
.
max_tokens
,
"max_new_tokens"
:
request
.
max_tokens
or
request
.
max_completion_tokens
,
"min_new_tokens"
:
request
.
min_tokens
,
"stop"
:
stop
,
"stop_token_ids"
:
request
.
stop_token_ids
,
...
...
python/sglang/srt/openai_api/protocol.py
View file @
05ee2192
...
...
@@ -320,7 +320,16 @@ class ChatCompletionRequest(BaseModel):
logit_bias
:
Optional
[
Dict
[
str
,
float
]]
=
None
logprobs
:
bool
=
False
top_logprobs
:
Optional
[
int
]
=
None
max_tokens
:
Optional
[
int
]
=
None
max_tokens
:
Optional
[
int
]
=
Field
(
default
=
None
,
deprecated
=
"max_tokens is deprecated in favor of the max_completion_tokens field"
,
description
=
"The maximum number of tokens that can be generated in the chat completion. "
,
)
max_completion_tokens
:
Optional
[
int
]
=
Field
(
default
=
None
,
description
=
"The maximum number of completion tokens for a chat completion request, "
"including visible output tokens and reasoning tokens. Input tokens are not included. "
,
)
n
:
int
=
1
presence_penalty
:
float
=
0.0
response_format
:
Optional
[
Union
[
ResponseFormat
,
StructuralTagResponseFormat
]]
=
None
...
...
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