test_prompt_validation.py 845 Bytes
Newer Older
1
2
# SPDX-License-Identifier: Apache-2.0

3
import pytest
4
import os
5
6

from vllm import LLM
7
from ...utils import models_path_prefix
8
9


Joe Runde's avatar
Joe Runde committed
10
11
12
13
14
15
16
17
@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


18
def test_empty_prompt():
zhuwenwen's avatar
zhuwenwen committed
19
    llm = LLM(model=os.path.join(models_path_prefix, "openai-community/gpt2"),, enforce_eager=True)
20
    with pytest.raises(ValueError, match='decoder prompt cannot be empty'):
21
        llm.generate([""])
22
23


Joe Runde's avatar
Joe Runde committed
24
@pytest.mark.skip_v1
25
def test_out_of_vocab_token():
zhuwenwen's avatar
zhuwenwen committed
26
    llm = LLM(model=os.path.join(models_path_prefix, "openai-community/gpt2"), enforce_eager=True)
27
28
    with pytest.raises(ValueError, match='out of vocabulary'):
        llm.generate({"prompt_token_ids": [999999]})