-
-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: empty prompt crashing the server (#912)
Co-authored-by: Max de Bayser <[email protected]>
- Loading branch information
1 parent
673621a
commit 16e5b2b
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
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 aphrodite 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,21 @@ | ||
# 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) |