Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions python/sglang/srt/openai_api/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -1723,6 +1723,26 @@ def v1_embedding_request(all_requests, tokenizer_manager):

for request in all_requests:
prompt = request.input
is_invalid = False

# Check for empty/whitespace string
if isinstance(prompt, str):
is_invalid = not prompt.strip()
# Check for various invalid list cases: [], [""], [" "], [[]]
elif isinstance(prompt, list):
is_invalid = not prompt or (
len(prompt) == 1
and (
(isinstance(prompt[0], str) and not prompt[0].strip())
or (isinstance(prompt[0], list) and not prompt[0])
)
)
if is_invalid:
raise HTTPException(
status_code=400,
detail="Input cannot be empty or contain only whitespace.",
)
# End of validation
assert (
type(prompt) is first_prompt_type
), "All prompts must be of the same type in file input settings"
Expand Down