[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
+13 -3
View File
@@ -40,6 +40,7 @@ from vllm.entrypoints.openai.responses.protocol import (
ResponseInputOutputItem,
ResponsesRequest,
)
from vllm.exceptions import VLLMValidationError
from vllm.logger import init_logger
from vllm.utils import random_uuid
@@ -88,7 +89,10 @@ def _parse_chat_format_message(chat_msg: dict) -> list[Message]:
"""Parse an OpenAI chat-format dict into Harmony messages."""
role = chat_msg.get("role")
if role is None:
raise ValueError(f"Message has no 'role' key: {chat_msg}")
raise VLLMValidationError(
f"Message has no 'role' key: {chat_msg}",
parameter="input",
)
# Assistant message with tool calls
tool_calls = chat_msg.get("tool_calls")
@@ -184,7 +188,10 @@ def response_input_to_harmony(
call_response = prev_response
break
if call_response is None:
raise ValueError(f"No call message found for {call_id}")
raise VLLMValidationError(
f"No call message found for {call_id}",
parameter="input",
)
msg = Message.from_author_and_content(
Author.new(Role.TOOL, f"functions.{call_response.name}"),
response_msg["output"],
@@ -205,7 +212,10 @@ def response_input_to_harmony(
msg = msg.with_recipient(f"functions.{response_msg['name']}")
msg = msg.with_content_type("json")
else:
raise ValueError(f"Unknown input type: {response_msg['type']}")
raise VLLMValidationError(
f"Unknown input type: {response_msg['type']}",
parameter="input",
)
return msg