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
0cf3fbeb
Unverified
Commit
0cf3fbeb
authored
Aug 18, 2025
by
gongwei-130
Committed by
GitHub
Aug 18, 2025
Browse files
should return invalide request for empty prompt (#9315)
parent
2256d62d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
1 deletion
+9
-1
python/sglang/srt/entrypoints/openai/serving_completions.py
python/sglang/srt/entrypoints/openai/serving_completions.py
+9
-1
No files found.
python/sglang/srt/entrypoints/openai/serving_completions.py
View file @
0cf3fbeb
import
logging
import
time
from
typing
import
Any
,
AsyncGenerator
,
Dict
,
List
,
Union
from
typing
import
Any
,
AsyncGenerator
,
Dict
,
List
,
Optional
,
Union
from
fastapi
import
Request
from
fastapi.responses
import
ORJSONResponse
,
StreamingResponse
...
...
@@ -41,6 +41,14 @@ class OpenAIServingCompletion(OpenAIServingBase):
def
_request_id_prefix
(
self
)
->
str
:
return
"cmpl-"
def
_validate_request
(
self
,
request
:
CompletionRequest
)
->
Optional
[
str
]:
"""Validate that the input is valid."""
prompt
=
request
.
prompt
if
not
prompt
or
(
isinstance
(
prompt
,
list
)
and
all
(
not
p
for
p
in
prompt
)):
return
"Prompt cannot be empty"
return
None
def
_convert_to_internal_request
(
self
,
request
:
CompletionRequest
,
...
...
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