Skip to content
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
eef1a19
+ tool_call
noooop Oct 10, 2026
842fbf6
+ types
noooop Oct 10, 2026
214154a
+ chat_template.py
noooop Oct 10, 2026
be90fe1
refine
noooop Oct 10, 2026
e4c38db
ChatTemplateResolutionError
noooop Oct 10, 2026
b7db6ae
+ __all__
noooop Oct 12, 2026
ffaa65b
Merge branch 'main' into split_chat_utils
noooop Oct 12, 2026
dc7cdf8
mypy
noooop Oct 12, 2026
63a7cdc
refine
noooop Oct 12, 2026
9dbe048
refine
noooop Oct 12, 2026
54fda3b
refine
noooop Oct 12, 2026
5558ed9
refine
noooop Oct 12, 2026
7836850
refine
noooop Oct 12, 2026
0e9fe07
Merge branch 'main' into split_chat_utils
noooop Oct 12, 2026
ccc3d4d
refine
noooop Oct 12, 2026
d1c7d4a
refine
noooop Oct 12, 2026
5c05311
mypy
noooop Oct 12, 2026
2eaebd0
mypy
noooop Oct 12, 2026
ba6b3a8
Merge branch 'main' into split_chat_utils
noooop Oct 13, 2026
cdac9b0
refine
noooop Oct 13, 2026
589390e
Merge branch 'main' into split_chat_utils
noooop Oct 13, 2026
8459c7e
refine
noooop Oct 13, 2026
7747f82
- mm_parser_map.py
noooop Oct 13, 2026
da950f8
refine
noooop Oct 13, 2026
8198e40
refine
noooop Oct 13, 2026
bc3731b
refine
noooop Oct 13, 2026
6bde9ab
refine
noooop Oct 13, 2026
3c40c74
Merge branch 'main' into split_chat_utils
noooop Oct 13, 2026
a459682
Merge branch 'main' into split_chat_utils
DarkLight1337 Oct 13, 2026
6c98d81
conflicts
noooop Oct 13, 2026
ac5a14d
Merge branch 'main' into split_chat_utils
noooop Oct 13, 2026
e4edbf7
conflicts
noooop Oct 13, 2026
37177cb
refine
noooop Oct 13, 2026
70aee47
Merge branch 'main' into split_chat_utils
noooop Oct 13, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions tests/entrypoints/cohere/test_serving_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ def test_text_only_list_preserves_per_block_text_parts(self):
# 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
Expand All @@ -533,7 +533,7 @@ def test_document_blocks_serialized_as_text_parts(self):
"""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
Expand Down Expand Up @@ -588,7 +588,7 @@ def test_document_only_content_serialized_as_text_part(self):
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``
Expand Down
4 changes: 2 additions & 2 deletions tests/entrypoints/unit_tests/test_chat_billing_header.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import pytest

from vllm.renderers.chat_utils import _parse_chat_message_content
from vllm.renderers.chat_utils import parse_chat_message_content
Comment thread
noooop marked this conversation as resolved.
Resolved

HEADER = (
"x-anthropic-billing-header: cc_version=2.1.220.300; "
Expand All @@ -17,7 +17,7 @@
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
)

Expand Down
2 changes: 1 addition & 1 deletion tests/models/multimodal/processing/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from vllm.multimodal.inputs import MultiModalFeatureSpec, batched_tensors_equal
from vllm.multimodal.processing import BaseMultiModalProcessor, InputProcessingContext
from vllm.platforms import current_platform
from vllm.renderers.chat_utils import _get_embeds_data
from vllm.renderers.chat_utils.item_tracker import _get_embeds_data
from vllm.tokenizers import TokenizerLike, cached_tokenizer_from_config
from vllm.utils.mistral import is_mistral_tokenizer

Expand Down
12 changes: 6 additions & 6 deletions tests/renderers/test_chat_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,24 @@
from vllm.config import ModelConfig
from vllm.exceptions import VLLMValidationError
from vllm.inputs import MultiModalDataDict, MultiModalUUIDDict
from vllm.multimodal.media import MEDIA_CONNECTOR_REGISTRY
from vllm.multimodal.utils import (
encode_audio_url,
encode_image_url,
encode_video_url,
)
from vllm.renderers.chat_utils import (
MEDIA_CONNECTOR_REGISTRY,
AsyncMultiModalItemTracker,
ChatCompletionMessageParam,
ConversationMessage,
_load_embeds_dict,
_parse_chat_message_content,
_parse_metadata_array,
_postprocess_messages,
parse_chat_message_content,
parse_chat_messages,
parse_chat_messages_async,
validate_chat_template,
)
from vllm.renderers.chat_utils.chat_message import _postprocess_messages
from vllm.renderers.chat_utils.content_parser import _load_embeds_dict
from vllm.renderers.chat_utils.item_tracker import _parse_metadata_array
from vllm.utils.serial_utils import tensor2base64

KIMI_K2_5_MODEL_ID = "moonshotai/Kimi-K2.5"
Expand Down Expand Up @@ -3205,7 +3205,7 @@ def _parse_one(message) -> ConversationMessage:
parser = tracker.create_parser.return_value
parser.model_config.enable_prompt_embeds = False
parser.mm_placeholder_storage.return_value = {}
result = _parse_chat_message_content(
result = parse_chat_message_content(
message, tracker, content_format="string", interleave_strings=False
)
assert len(result) == 1
Expand Down
9 changes: 5 additions & 4 deletions tests/renderers/test_chat_utils_prompt_embeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,16 @@

from vllm.exceptions import VLLMValidationError
from vllm.renderers import TokenizeParams
from vllm.renderers.chat_utils import (
_ENABLE_PROMPT_EMBEDS_ERROR,
from vllm.renderers.chat_utils import parse_chat_messages, parse_chat_messages_async
from vllm.renderers.chat_utils.chat_message import (
_PROMPT_EMBEDS_MISSING_DATA_ERROR,
_RESERVED_PLACEHOLDER_IN_TEXT_ERROR,
MM_PARSER_MAP,
)
from vllm.renderers.chat_utils.content_parser import (
_ENABLE_PROMPT_EMBEDS_ERROR,
MODALITY_PLACEHOLDERS_MAP,
PROMPT_EMBEDS_PLACEHOLDER_TOKEN,
parse_chat_messages,
parse_chat_messages_async,
)
from vllm.renderers.hf import (
_PROMPT_EMBEDS_PLACEHOLDER_SPAN_MISMATCH_ERROR,
Expand Down
2 changes: 1 addition & 1 deletion tests/renderers/test_warmup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@

import pytest

from vllm.exceptions import ChatTemplateResolutionError
from vllm.multimodal.processing import BaseMultiModalProcessor
from vllm.renderers.base import BaseRenderer
from vllm.renderers.chat_utils import ChatTemplateResolutionError
from vllm.renderers.params import ChatParams


Expand Down
2 changes: 1 addition & 1 deletion vllm/entrypoints/cohere/serving.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ def _convert_tool_message(cls, msg: ToolChatMessageV2) -> dict[str, Any]:
# Map every content block to a plain ``{"type": "text", "text":
# ...}`` part, mirroring the shape :meth:`_convert_user_message`
# emits for multi-part user content. vLLM's
# ``_parse_chat_message_content`` collapses a text-only tool
# ``parse_chat_message_content`` collapses a text-only tool
# part list back into ``"\n".join(...)`` on the way to the
# renderer, so simple chat templates that expect string tool
# content still work; keeping the list here just preserves the
Expand Down
2 changes: 1 addition & 1 deletion vllm/entrypoints/pooling/embed/io_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
ChatCompletionContentPartImageParam,
ChatCompletionContentPartTextParam,
)
from openai.types.chat.chat_completion_content_part_image_param import ImageURL

from vllm import PoolingParams
from vllm.inputs import tokens_input
Expand All @@ -20,6 +19,7 @@
ChatCompletionContentPartParam,
ChatCompletionMessageParam,
CustomChatCompletionMessageParam,
ImageURL,
)
from vllm.renderers.hf import resolve_chat_template
from vllm.utils.collection_utils import chunk_list
Expand Down
2 changes: 1 addition & 1 deletion vllm/entrypoints/pooling/scoring/io_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
import torch.nn.functional as F

from vllm import PoolingParams, PoolingRequestOutput, TokensPrompt
from vllm.exceptions import ChatTemplateResolutionError
from vllm.logger import init_logger
from vllm.renderers import TokenizeParams
from vllm.renderers.chat_utils import ChatTemplateResolutionError
from vllm.renderers.hf import safe_apply_chat_template
from vllm.renderers.inputs.preprocess import (
extract_target_prompt,
Expand Down
4 changes: 2 additions & 2 deletions vllm/entrypoints/pooling/scoring/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
ChatCompletionContentPartTextParam,
ConversationMessage,
MultiModalItemTracker,
_parse_chat_message_content_parts,
parse_chat_message_content_parts,
)

from .typing import (
Expand Down Expand Up @@ -193,7 +193,7 @@ def _parse_score_content(

mm_parser = mm_tracker.create_parser()

parse_res = _parse_chat_message_content_parts(
parse_res = parse_chat_message_content_parts(
role=role,
parts=parts,
mm_tracker=mm_tracker,
Expand Down
6 changes: 6 additions & 0 deletions vllm/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ class VLLMNotFoundError(VLLMClientError):
pass


class ChatTemplateResolutionError(VLLMClientError):
"""Raised when chat template resolution fails."""

pass


class LoRAAdapterNotFoundError(VLLMNotFoundError):
"""Exception raised when a LoRA adapter is not found.

Expand Down
2 changes: 1 addition & 1 deletion vllm/renderers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ def warmup(self, chat_params: ChatParams) -> None:
no-op if the background warmup — or a prior reset_mm_cache that joined
it — already ran it.
"""
from vllm.renderers.chat_utils import ChatTemplateResolutionError
from vllm.exceptions import ChatTemplateResolutionError

# prevent MM processor hangs
with set_default_torch_num_threads(1):
Expand Down
Loading
Loading