Skip to content

Commit 9a61e63

Browse files
committed
move model_config after *
Signed-off-by: Linkun <github@lkchen.net>
1 parent 55aa7af commit 9a61e63

File tree

4 files changed

+19
-10
lines changed

4 files changed

+19
-10
lines changed

tests/entrypoints/test_chat_utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -903,11 +903,11 @@ def test_resolve_content_format_hf_defined(model, expected_format):
903903
print(_try_extract_ast(chat_template))
904904

905905
resolved_format = resolve_chat_template_content_format(
906-
model_config,
907906
None, # Test detecting the tokenizer's chat_template
908907
None,
909908
"auto",
910909
tokenizer,
910+
model_config=model_config,
911911
)
912912

913913
assert resolved_format == expected_format
@@ -962,11 +962,11 @@ def test_resolve_content_format_fallbacks(model, expected_format):
962962
print(_try_extract_ast(chat_template))
963963

964964
resolved_format = resolve_chat_template_content_format(
965-
model_config,
966965
None, # Test detecting the tokenizer's chat_template
967966
None,
968967
"auto",
969968
tokenizer,
969+
model_config=model_config,
970970
)
971971

972972
assert resolved_format == expected_format
@@ -1021,11 +1021,11 @@ def test_resolve_content_format_examples(template_path, expected_format):
10211021
print(_try_extract_ast(chat_template))
10221022

10231023
resolved_format = resolve_chat_template_content_format(
1024-
model_config,
10251024
chat_template,
10261025
None,
10271026
"auto",
10281027
dummy_tokenizer,
1028+
model_config=model_config,
10291029
)
10301030

10311031
assert resolved_format == expected_format

vllm/entrypoints/chat_utils.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -330,10 +330,13 @@ def resolve_mistral_chat_template(
330330
return None
331331

332332
def resolve_hf_chat_template(
333-
model_config: ModelConfig,
334333
tokenizer: Union[PreTrainedTokenizer, PreTrainedTokenizerFast],
335334
chat_template: Optional[str],
336335
tools: Optional[list[dict[str, Any]]],
336+
*,
337+
model_config: ModelConfig,
338+
# For backwards compatibility, keep deprecated args as kwargs
339+
**kwargs: dict[str, Any],
337340
) -> Optional[str]:
338341
# 1st priority: The given chat template
339342
if chat_template is not None:
@@ -379,18 +382,21 @@ def resolve_hf_chat_template(
379382

380383

381384
def _resolve_chat_template_content_format(
382-
model_config: ModelConfig,
383385
chat_template: Optional[str],
384386
tools: Optional[list[dict[str, Any]]],
385387
given_format: ChatTemplateContentFormatOption,
386388
tokenizer: AnyTokenizer,
389+
*,
390+
model_config: ModelConfig,
391+
# For backwards compatibility, keep deprecated args as kwargs
392+
**kwargs: dict[str, Any],
387393
) -> _ChatTemplateContentFormat:
388394
if isinstance(tokenizer, (PreTrainedTokenizer, PreTrainedTokenizerFast)):
389395
hf_chat_template = resolve_hf_chat_template(
390-
model_config,
391396
tokenizer,
392397
chat_template=chat_template,
393398
tools=tools,
399+
model_config=model_config,
394400
)
395401
else:
396402
hf_chat_template = None
@@ -429,18 +435,21 @@ def _log_chat_template_content_format(
429435

430436

431437
def resolve_chat_template_content_format(
432-
model_config: ModelConfig,
433438
chat_template: Optional[str],
434439
tools: Optional[list[dict[str, Any]]],
435440
given_format: ChatTemplateContentFormatOption,
436441
tokenizer: AnyTokenizer,
442+
*,
443+
model_config: ModelConfig,
444+
# For backwards compatibility, keep deprecated args as kwargs
445+
**kwargs: dict[str, Any],
437446
) -> _ChatTemplateContentFormat:
438447
detected_format = _resolve_chat_template_content_format(
439-
model_config,
440448
chat_template,
441449
tools,
442450
given_format,
443451
tokenizer,
452+
model_config=model_config,
444453
)
445454

446455
_log_chat_template_content_format(

vllm/entrypoints/llm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -731,11 +731,11 @@ def chat(
731731
tokenizer = self.get_tokenizer(lora_request)
732732
model_config = self.llm_engine.get_model_config()
733733
resolved_content_format = resolve_chat_template_content_format(
734-
model_config,
735734
chat_template,
736735
tools,
737736
chat_template_content_format,
738737
tokenizer,
738+
model_config=model_config,
739739
)
740740

741741
_chat_template_kwargs: dict[str, Any] = dict(

vllm/entrypoints/openai/serving_engine.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -670,11 +670,11 @@ async def _preprocess_chat(
670670
model_config = self.model_config
671671

672672
resolved_content_format = resolve_chat_template_content_format(
673-
model_config,
674673
chat_template,
675674
tool_dicts,
676675
chat_template_content_format,
677676
tokenizer,
677+
model_config=model_config,
678678
)
679679
conversation, mm_data_future = parse_chat_messages_futures(
680680
messages,

0 commit comments

Comments
 (0)