[Misc] Break chat_utils into more maintainable modules. (#60972)
Signed-off-by: wang.yuqi <yuqi.wang@daocloud.io>
This commit is contained in:
@@ -511,7 +511,7 @@ class TestConvertToolMessage:
|
||||
# A list of text blocks maps 1-to-1 onto ``text`` content
|
||||
# parts, mirroring the shape ``_convert_user_message`` emits
|
||||
# for multi-part user content. vLLM's
|
||||
# ``_parse_chat_message_content`` will collapse this back to
|
||||
# ``parse_chat_message_content`` will collapse this back to
|
||||
# ``"\n".join(...)`` for the ``ConversationMessage`` handed to
|
||||
# renderers (see the tool-role branch in
|
||||
# ``vllm/entrypoints/chat_utils.py``), so downstream chat
|
||||
@@ -533,7 +533,7 @@ class TestConvertToolMessage:
|
||||
"""Document blocks must not survive on the OpenAI-shaped tool
|
||||
message.
|
||||
|
||||
vLLM's shared ``_parse_chat_message_content_parts`` runs a
|
||||
vLLM's shared ``parse_chat_message_content_parts`` runs a
|
||||
Pydantic ``ValidatorIterator`` over the OpenAI content-part
|
||||
union, which only knows ``text`` / ``image_url`` / etc. and
|
||||
rejects ``{"type": "document", ...}`` blocks outright. We
|
||||
@@ -588,7 +588,7 @@ class TestConvertToolMessage:
|
||||
def test_converted_tool_message_content_survives_openai_validation(self):
|
||||
"""Regression for the reported crash.
|
||||
|
||||
``vllm/entrypoints/chat_utils.py:_parse_chat_message_content_parts``
|
||||
``vllm/renders/chat_message_content.py:parse_chat_message_content_parts``
|
||||
runs a Pydantic ``ValidatorIterator`` over
|
||||
``list[ChatCompletionContentPartParam]``, which is a
|
||||
discriminated union that only accepts ``text`` / ``image_url``
|
||||
|
||||
@@ -6,7 +6,7 @@ from unittest.mock import MagicMock
|
||||
|
||||
import pytest
|
||||
|
||||
from vllm.renderers.chat_utils import _parse_chat_message_content
|
||||
from vllm.renderers.chat_utils import parse_chat_message_content
|
||||
|
||||
HEADER = (
|
||||
"x-anthropic-billing-header: cc_version=2.1.220.300; "
|
||||
@@ -17,7 +17,7 @@ HEADER = (
|
||||
def _parse(message, content_format="openai"):
|
||||
tracker = MagicMock()
|
||||
tracker.create_parser.return_value.mm_placeholder_storage.return_value = {}
|
||||
return _parse_chat_message_content(
|
||||
return parse_chat_message_content(
|
||||
message, tracker, content_format, interleave_strings=False
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user