forked from vllm-project/vllm
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BugFix] Fix server crash on empty prompt (vllm-project#7746)
Signed-off-by: Max de Bayser <[email protected]>
- Loading branch information
1 parent
faeddb5
commit e25fee5
Showing
3 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import pytest | ||
|
||
from vllm import LLM | ||
|
||
|
||
def test_empty_prompt(): | ||
llm = LLM(model="gpt2") | ||
with pytest.raises(ValueError, match='Prompt cannot be empty'): | ||
llm.generate([""]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# imports for guided decoding tests | ||
import re | ||
|
||
import openai | ||
import pytest | ||
|
||
from ...utils import RemoteOpenAIServer | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_empty_prompt(): | ||
model_name = "gpt2" | ||
server_args = ["--enforce-eager"] | ||
with RemoteOpenAIServer(model_name, server_args) as remote_server: | ||
client = remote_server.get_async_client() | ||
|
||
with pytest.raises(openai.BadRequestError, | ||
match=re.compile('.+Prompt cannot be empty.+')): | ||
await client.completions.create(model=model_name, | ||
prompt="", | ||
max_tokens=5, | ||
temperature=0.0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters