diff --git a/tests/entrypoints/unit_tests/test_chat_utils.py b/tests/entrypoints/unit_tests/test_chat_utils.py index fe190a2f18..2778770e37 100644 --- a/tests/entrypoints/unit_tests/test_chat_utils.py +++ b/tests/entrypoints/unit_tests/test_chat_utils.py @@ -2092,7 +2092,7 @@ def test_parse_chat_messages_multiple_images_interleave_with_placeholders( image_url, ): with pytest.raises( - ValueError, + VLLMValidationError, match=r"Found more '<|image_1|>' placeholders in input prompt " "than actual multimodal data items.", ): diff --git a/tests/renderers/test_chat_utils_prompt_embeds.py b/tests/renderers/test_chat_utils_prompt_embeds.py index 3f08194b9b..b537d2a13a 100644 --- a/tests/renderers/test_chat_utils_prompt_embeds.py +++ b/tests/renderers/test_chat_utils_prompt_embeds.py @@ -316,7 +316,7 @@ _PLACEHOLDER_ERROR_PATTERN: Final[str] = re.sub( def test_parse_chat_messages_rejects_placeholder_in_user_text(content): mc = _make_mock_model_config() # enable_prompt_embeds=True by default messages = [{"role": "user", "content": content}] - with pytest.raises(ValueError, match=_PLACEHOLDER_ERROR_PATTERN): + with pytest.raises(VLLMValidationError, match=_PLACEHOLDER_ERROR_PATTERN): parse_chat_messages(messages, mc, content_format="openai") diff --git a/vllm/entrypoints/chat_utils.py b/vllm/entrypoints/chat_utils.py index f2f8498849..2f8e11714b 100644 --- a/vllm/entrypoints/chat_utils.py +++ b/vllm/entrypoints/chat_utils.py @@ -467,7 +467,7 @@ def _merge_embeds( first_keys = set(data_items[0].keys()) if any(set(item.keys()) != first_keys for item in data_items[1:]): - raise ValueError( + raise VLLMValidationError( "All dictionaries in the list of embeddings must have the same keys." ) @@ -746,9 +746,15 @@ def _resolve_items( modality requires a processor, enforced by the guard below. """ if "image" in items_by_modality and "image_embeds" in items_by_modality: - raise ValueError("Mixing raw image and embedding inputs is not allowed") + raise VLLMValidationError( + "Mixing raw image and embedding inputs is not allowed", + parameter="image_embeds", + ) if "audio" in items_by_modality and "audio_embeds" in items_by_modality: - raise ValueError("Mixing raw audio and embedding inputs is not allowed") + raise VLLMValidationError( + "Mixing raw audio and embedding inputs is not allowed", + parameter="audio_embeds", + ) # `prompt_embeds` bypasses HF MM processors. Every other modality requires one. processor_modalities = items_by_modality.keys() - {"prompt_embeds"} if processor_modalities and mm_processor is None: @@ -1448,7 +1454,7 @@ def _get_full_multimodal_text_prompt( interleave_strings, ) logger.debug("Input prompt: %s", text_prompt) - raise ValueError( + raise VLLMValidationError( f"Found more '{placeholder}' placeholders in input prompt than " "actual multimodal data items." ) @@ -1696,7 +1702,7 @@ def _reject_reserved_placeholder_in_text(text: str, model_config: ModelConfig) - caller move or inject splice positions via plain text content. """ if model_config.enable_prompt_embeds and PROMPT_EMBEDS_PLACEHOLDER_TOKEN in text: - raise ValueError( + raise VLLMValidationError( _RESERVED_PLACEHOLDER_IN_TEXT_ERROR.format( token=PROMPT_EMBEDS_PLACEHOLDER_TOKEN )