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

4
5
6
7
8
import pytest

from vllm import LLM


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


17
def test_empty_prompt():
18
    llm = LLM(model="openai-community/gpt2", enforce_eager=True)
19
    with pytest.raises(ValueError, match='decoder prompt cannot be empty'):
20
        llm.generate([""])
21
22


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