test_prompt_validation.py 692 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
11


def test_empty_prompt():
zhuwenwen's avatar
zhuwenwen committed
12
    llm = LLM(model=os.path.join(models_path_prefix, "openai-community/gpt2"), enforce_eager=True)
13
    with pytest.raises(ValueError, match='decoder prompt cannot be empty'):
14
        llm.generate([""])
15
16


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