[Frontend] Improve error message for too many mm items (#22114)

Signed-off-by: DarkLight1337 <tlleungac@connect.ust.hk>
This commit is contained in:
Cyrus Leung
2025-08-02 02:20:38 -07:00
committed by GitHub
parent b690e34824
commit f5d0f4784f
5 changed files with 52 additions and 51 deletions
+2 -8
View File
@@ -579,10 +579,7 @@ def test_parse_chat_messages_rejects_too_many_images_in_one_message(
warnings.filterwarnings(
"ignore",
message="coroutine 'async_get_and_parse_image' was never awaited")
with pytest.raises(
ValueError,
match="At most 2 image\\(s\\) may be provided in one request\\."
):
with pytest.raises(ValueError, match="At most"):
parse_chat_messages(
[{
"role":
@@ -622,10 +619,7 @@ def test_parse_chat_messages_rejects_too_many_images_across_messages(
warnings.filterwarnings(
"ignore",
message="coroutine 'async_get_and_parse_image' was never awaited")
with pytest.raises(
ValueError,
match="At most 2 image\\(s\\) may be provided in one request\\."
):
with pytest.raises(ValueError, match="At most"):
parse_chat_messages(
[{
"role":
+4 -6
View File
@@ -3,7 +3,6 @@
from contextlib import nullcontext
from typing import Optional, cast
from unittest.mock import MagicMock
import numpy as np
import pytest
@@ -957,15 +956,14 @@ def test_limit_mm_per_prompt_dummy(model_id, limit, num_supported, is_valid):
)
processor = MULTIMODAL_REGISTRY.create_processor(model_config)
profiler = MultiModalProfiler(processor)
processor._supported_mm_limits = {"image": num_supported}
mock_supported_mm_limits = MagicMock(return_value={"image": num_supported})
processor.info.get_supported_mm_limits = mock_supported_mm_limits
profiler = MultiModalProfiler(processor)
if is_valid:
exc_ctx = nullcontext()
else:
exc_ctx = pytest.raises(ValueError, match="The model only supports")
exc_ctx = pytest.raises(ValueError, match="At most")
with exc_ctx:
profiler.get_decoder_dummy_data(
@@ -1002,7 +1000,7 @@ def test_limit_mm_per_prompt_apply(model_id, num_images, limit, is_valid):
if is_valid:
exc_ctx = nullcontext()
else:
exc_ctx = pytest.raises(ValueError, match=f"passed {num_images} image")
exc_ctx = pytest.raises(ValueError, match="At most")
with exc_ctx:
processor.apply(