# SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project from collections.abc import Callable from pathlib import Path from typing import TypeAlias from vllm.logger import init_logger logger = init_logger(__file__) CHAT_TEMPLATES_DIR = Path(__file__).parent ChatTemplatePath: TypeAlias = Path | Callable[[str], Path | None] _MODEL_TYPE_TO_CHAT_TEMPLATE_FALLBACK: dict[str, ChatTemplatePath] = {} def get_chat_template_fallback_path( model_type: str, tokenizer_name_or_path: str, ) -> Path | None: chat_template = _MODEL_TYPE_TO_CHAT_TEMPLATE_FALLBACK.get(model_type) if callable(chat_template): chat_template = chat_template(tokenizer_name_or_path) if chat_template is None: return None return chat_template