[Frontend] Replace return_mm_kwargs with an mm_payload enum on render requests (#61427)
Signed-off-by: Martin Hickey <martin.hickey@ie.ibm.com>
This commit is contained in:
@@ -8,6 +8,10 @@ import pytest
|
||||
import torch
|
||||
from pydantic import ValidationError
|
||||
|
||||
from vllm.entrypoints.anthropic.protocol import AnthropicMessagesRequest
|
||||
from vllm.entrypoints.openai.chat_completion.protocol import ChatCompletionRequest
|
||||
from vllm.entrypoints.openai.completion.protocol import CompletionRequest
|
||||
from vllm.entrypoints.openai.responses.protocol import ResponsesRequest
|
||||
from vllm.entrypoints.scale_out.token_in_token_out.mm_features import (
|
||||
extract_mm_features,
|
||||
merge_mm_kwargs_items,
|
||||
@@ -173,7 +177,7 @@ def test_extract_without_kwargs_keeps_layout():
|
||||
engine_input, _pixel_values, _image_grid_thw = _image_engine_input()
|
||||
|
||||
full = extract_mm_features(engine_input)
|
||||
layout = extract_mm_features(engine_input, include_mm_kwargs=False)
|
||||
layout = extract_mm_features(engine_input, mm_payload="none")
|
||||
|
||||
assert full is not None and layout is not None
|
||||
assert layout.kwargs_data is None
|
||||
@@ -182,6 +186,40 @@ def test_extract_without_kwargs_keeps_layout():
|
||||
assert layout.mm_placeholders == full.mm_placeholders
|
||||
|
||||
|
||||
_MESSAGES = [{"role": "user", "content": "hi"}]
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("request_cls", "body"),
|
||||
[
|
||||
(ChatCompletionRequest, {"model": "m", "messages": _MESSAGES}),
|
||||
(CompletionRequest, {"model": "m", "prompt": "hi"}),
|
||||
(ResponsesRequest, {"model": "m", "input": "hi"}),
|
||||
(
|
||||
AnthropicMessagesRequest,
|
||||
{"model": "m", "max_tokens": 8, "messages": _MESSAGES},
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_return_mm_kwargs_is_alias_for_mm_payload(request_cls, body):
|
||||
"""Clients of the deprecated bool keep getting layout-only responses."""
|
||||
assert request_cls.model_validate(body).mm_payload == "tensors"
|
||||
|
||||
for return_mm_kwargs, expected in [(False, "none"), (True, "tensors")]:
|
||||
request = request_cls.model_validate(
|
||||
{**body, "return_mm_kwargs": return_mm_kwargs}
|
||||
)
|
||||
assert request.mm_payload == expected
|
||||
|
||||
explicit = request_cls.model_validate(
|
||||
{**body, "return_mm_kwargs": False, "mm_payload": "tensors"}
|
||||
)
|
||||
assert explicit.mm_payload == "tensors"
|
||||
|
||||
with pytest.raises(ValidationError):
|
||||
request_cls.model_validate({**body, "mm_payload": "source"})
|
||||
|
||||
|
||||
def test_extract_includes_declared_placeholder_metadata_fields():
|
||||
"""EC placeholder metadata is kept even when keep_on_cpu is unset."""
|
||||
engine_input, _pixel_values, image_grid_thw = _image_engine_input(
|
||||
|
||||
Reference in New Issue
Block a user