[Frontend] Lazily initialize chat media connectors (#49914)
Signed-off-by: Andreas Karatzas <akaratza@amd.com>
This commit is contained in:
@@ -15,6 +15,7 @@ from vllm.assets.image import ImageAsset
|
||||
from vllm.assets.video import VideoAsset
|
||||
from vllm.config import ModelConfig
|
||||
from vllm.entrypoints.chat_utils import (
|
||||
MEDIA_CONNECTOR_REGISTRY,
|
||||
AsyncMultiModalItemTracker,
|
||||
ConversationMessage,
|
||||
_postprocess_messages,
|
||||
@@ -709,6 +710,29 @@ def test_parse_chat_messages_empty_system(
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_text_only_chat_does_not_initialize_media_connector(
|
||||
mistral_model_config,
|
||||
monkeypatch,
|
||||
):
|
||||
load_connector = MagicMock()
|
||||
monkeypatch.setattr(MEDIA_CONNECTOR_REGISTRY, "load", load_connector)
|
||||
messages = [{"role": "user", "content": "Who are you?"}]
|
||||
|
||||
parse_chat_messages(
|
||||
messages,
|
||||
mistral_model_config,
|
||||
content_format="string",
|
||||
)
|
||||
await parse_chat_messages_async(
|
||||
messages,
|
||||
mistral_model_config,
|
||||
content_format="string",
|
||||
)
|
||||
|
||||
load_connector.assert_not_called()
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_parse_chat_messages_single_image_async(
|
||||
phi3v_model_config,
|
||||
|
||||
Reference in New Issue
Block a user