@tduncan / Nvidia-Optimization-Stack-VLLM Mirror · read-only / commits / 5e021b4981
Fork 0

A high-throughput and memory-efficient inference and serving engine for LLMs

Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git

Synced Nov 14, 05:30 UTC

(Misc): add missing test for zero truncation size. (#23457)

Signed-off-by: teekenl <teekenlau@gmail.com>

TeeKen Lau committed Aug 24, 2025 at 20:12 UTC 5e021b4981c14724b57744df182d876e6a07e4b9
1 file changed +22
tests/entrypoints/openai/test_truncation.py
+22
@@ -64,6 +64,28 @@ async def test_smaller_truncation_size(client: openai.AsyncOpenAI):
64 assert response["usage"]["prompt_tokens"] == truncation_size
65
66
67 +@pytest.mark.asyncio
68 +async def test_zero_truncation_size(client: openai.AsyncOpenAI):
69 + truncation_size = 0
70 + kwargs: dict[str, Any] = {
71 + "model": MODEL_NAME,
72 + "input": input,
73 + "truncate_prompt_tokens": truncation_size
74 + }
75 +
76 + with pytest.raises(openai.BadRequestError) as err:
77 + await client.post(path="embeddings", cast_to=object, body={**kwargs})
78 +
79 + assert err.value.status_code == 400
80 + error_details = err.value.response.json()["error"]
81 +
82 + assert error_details["type"] == "BadRequestError"
83 + assert "This model's maximum context length is" in error_details["message"]
84 + assert "tokens in the input for embedding generation" in error_details[
85 + "message"]
86 + assert "Please reduce the length of the input" in error_details["message"]
87 +
88 +
89 @pytest.mark.asyncio
90 async def test_bigger_truncation_size(client: openai.AsyncOpenAI):
91 truncation_size = max_model_len + 1