[Frontend] Fix chat template content format detection (#18190)

Signed-off-by: Sebastian Schönnenbeck <sebastian.schoennenbeck@comma-soft.com>
This commit is contained in:
Sebastian Schoennenbeck 2025-05-15 18:00:21 +02:00 committed by GitHub
parent 51ff154639
commit 2aa5470ac5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -387,7 +387,6 @@ def resolve_hf_chat_template(
def _resolve_chat_template_content_format( def _resolve_chat_template_content_format(
chat_template: Optional[str], chat_template: Optional[str],
tools: Optional[list[dict[str, Any]]], tools: Optional[list[dict[str, Any]]],
given_format: ChatTemplateContentFormatOption,
tokenizer: AnyTokenizer, tokenizer: AnyTokenizer,
*, *,
model_config: ModelConfig, model_config: ModelConfig,
@ -408,7 +407,7 @@ def _resolve_chat_template_content_format(
detected_format = ("string" if jinja_text is None else detected_format = ("string" if jinja_text is None else
_detect_content_format(jinja_text, default="string")) _detect_content_format(jinja_text, default="string"))
return detected_format if given_format == "auto" else given_format return detected_format
@lru_cache @lru_cache
@ -451,7 +450,6 @@ def resolve_chat_template_content_format(
detected_format = _resolve_chat_template_content_format( detected_format = _resolve_chat_template_content_format(
chat_template, chat_template,
tools, tools,
given_format,
tokenizer, tokenizer,
model_config=model_config, model_config=model_config,
) )
@ -462,7 +460,8 @@ def resolve_chat_template_content_format(
detected_format=detected_format, detected_format=detected_format,
) )
return detected_format return detected_format if given_format == "auto" else given_format
ModalityStr = Literal["image", "audio", "video", "image_embeds"] ModalityStr = Literal["image", "audio", "video", "image_embeds"]