"vllm/vscode:/vscode.git/clone" did not exist on "6874638bc443ae99ee900072e0bb039fa5f7f0e7"
test_prompt_validation.py 913 Bytes
Newer Older
1
# SPDX-License-Identifier: Apache-2.0
2
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3

4
import pytest
5
import os
6
7

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


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


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


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