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
norm
vllm
Commits
bbbf8656
Unverified
Commit
bbbf8656
authored
Sep 24, 2023
by
Wen Sun
Committed by
GitHub
Sep 23, 2023
Browse files
Align `max_tokens` behavior with openai (#852)
parent
9f6be869
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
1 deletion
+3
-1
vllm/entrypoints/openai/api_server.py
vllm/entrypoints/openai/api_server.py
+2
-0
vllm/entrypoints/openai/protocol.py
vllm/entrypoints/openai/protocol.py
+1
-1
No files found.
vllm/entrypoints/openai/api_server.py
View file @
bbbf8656
...
@@ -130,6 +130,8 @@ async def check_length(
...
@@ -130,6 +130,8 @@ async def check_length(
input_ids
=
tokenizer
(
prompt
).
input_ids
input_ids
=
tokenizer
(
prompt
).
input_ids
token_num
=
len
(
input_ids
)
token_num
=
len
(
input_ids
)
if
request
.
max_tokens
is
None
:
request
.
max_tokens
=
max_model_len
-
token_num
if
token_num
+
request
.
max_tokens
>
max_model_len
:
if
token_num
+
request
.
max_tokens
>
max_model_len
:
return
input_ids
,
create_error_response
(
return
input_ids
,
create_error_response
(
HTTPStatus
.
BAD_REQUEST
,
HTTPStatus
.
BAD_REQUEST
,
...
...
vllm/entrypoints/openai/protocol.py
View file @
bbbf8656
...
@@ -58,7 +58,7 @@ class ChatCompletionRequest(BaseModel):
...
@@ -58,7 +58,7 @@ class ChatCompletionRequest(BaseModel):
temperature
:
Optional
[
float
]
=
0.7
temperature
:
Optional
[
float
]
=
0.7
top_p
:
Optional
[
float
]
=
1.0
top_p
:
Optional
[
float
]
=
1.0
n
:
Optional
[
int
]
=
1
n
:
Optional
[
int
]
=
1
max_tokens
:
Optional
[
int
]
=
16
max_tokens
:
Optional
[
int
]
=
None
stop
:
Optional
[
Union
[
str
,
List
[
str
]]]
=
Field
(
default_factory
=
list
)
stop
:
Optional
[
Union
[
str
,
List
[
str
]]]
=
Field
(
default_factory
=
list
)
stream
:
Optional
[
bool
]
=
False
stream
:
Optional
[
bool
]
=
False
presence_penalty
:
Optional
[
float
]
=
0.0
presence_penalty
:
Optional
[
float
]
=
0.0
...
...
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