[Frontend] Migrate Responses harmony input validation to VLLMValidationError (#55701)

Signed-off-by: shaolila <shaolila@buaa.edu.cn>
Co-authored-by: shaolila <shaolila@buaa.edu.cn>
This commit is contained in:
Adababy
2026-09-07 13:30:11 +00:00
committed by GitHub
co-authored by shaolila
parent b339d75a41
commit 167858ea17
3 changed files with 36 additions and 7 deletions
@@ -16,6 +16,7 @@ from vllm.entrypoints.openai.responses.harmony import (
harmony_to_response_output,
response_previous_input_to_harmony,
)
from vllm.exceptions import VLLMValidationError
class TestResponsePreviousInputToHarmony:
@@ -92,6 +93,16 @@ class TestResponsePreviousInputToHarmony:
assert messages[0].author.name == "functions.empty_tool"
assert messages[0].content[0].text == ""
def test_chat_message_without_role_raises_validation_error(self):
"""A chat-format message missing the 'role' key is invalid input."""
chat_msg = {"content": "hello, no role here"}
with pytest.raises(
VLLMValidationError, match="Message has no 'role' key"
) as exc_info:
response_previous_input_to_harmony(chat_msg)
assert exc_info.value.parameter == "input"
class TestHarmonyToResponseOutput:
"""Tests for harmony_to_response_output function."""