test_prompt_validation.py 645 Bytes
Newer Older
1
2
3
4
5
import pytest

from vllm import LLM


Joe Runde's avatar
Joe Runde committed
6
7
8
9
10
11
12
13
@pytest.fixture(autouse=True)
def v1(run_with_both_engines):
    # Simple autouse wrapper to run both engines for each test
    # This can be promoted up to conftest.py to run for every
    # test in a package
    pass


14
def test_empty_prompt():
15
    llm = LLM(model="gpt2", enforce_eager=True)
16
17
    with pytest.raises(ValueError, match='Prompt cannot be empty'):
        llm.generate([""])
18
19


Joe Runde's avatar
Joe Runde committed
20
@pytest.mark.skip_v1
21
22
23
24
def test_out_of_vocab_token():
    llm = LLM(model="gpt2", enforce_eager=True)
    with pytest.raises(ValueError, match='out of vocabulary'):
        llm.generate({"prompt_token_ids": [999999]})