[Bugfix] complete VLLMValidationError migration in chat_utils.py (#50254)

Signed-off-by: shaolila <shaolila@buaa.edu.cn>
Co-authored-by: shaolila <shaolila@buaa.edu.cn>
This commit is contained in:
Adababy
2026-09-05 17:56:12 +08:00
committed by GitHub
co-authored by shaolila
parent e473e9036f
commit 2902ca17e3
3 changed files with 12 additions and 7 deletions
+8 -5
View File
@@ -1446,10 +1446,11 @@ def validate_chat_template(chat_template: Path | str | None):
builtin_template_path = CHAT_TEMPLATES_DIR / chat_template
if not builtin_template_path.exists():
raise ValueError(
raise VLLMValidationError(
f"The supplied chat template string ({chat_template}) "
f"appears path-like, but doesn't exist! "
f"Tried: {chat_template} and {builtin_template_path}"
f"Tried: {chat_template} and {builtin_template_path}",
parameter="chat_template",
)
else:
@@ -1497,7 +1498,7 @@ def _load_chat_template(
f"Tried: {chat_template} and {builtin_template_path}. "
f"Reason: {e}"
)
raise ValueError(msg) from e
raise VLLMValidationError(msg, parameter="chat_template") from e
# If opening a file fails, set chat template to be args to
# ensure we decode so our escape are interpreted correctly
@@ -1575,7 +1576,8 @@ def _get_full_multimodal_text_prompt(
logger.debug("Input prompt: %s", text_prompt)
raise VLLMValidationError(
f"Found more '{placeholder}' placeholders in input prompt than "
"actual multimodal data items."
"actual multimodal data items.",
parameter="messages",
)
missing_placeholders.extend([placeholder] * placeholder_counts[placeholder])
@@ -1833,7 +1835,8 @@ def _reject_reserved_placeholder_in_text(text: str, model_config: ModelConfig) -
raise VLLMValidationError(
_RESERVED_PLACEHOLDER_IN_TEXT_ERROR.format(
token=PROMPT_EMBEDS_PLACEHOLDER_TOKEN
)
),
parameter="messages",
)