[Feature]support chat_template.jinja (#3721)

* add support chat_template.jinja

* add support chat_template.jinja
This commit is contained in:
luukunn
2025-08-30 17:05:34 +08:00
committed by GitHub
parent b21e085f3e
commit 9a7c231f2c
3 changed files with 9 additions and 2 deletions

View File

@@ -14,6 +14,7 @@
# limitations under the License.
"""
import os
import uuid
from copy import deepcopy
from pathlib import Path
@@ -162,9 +163,15 @@ def parse_chat_messages(messages):
def load_chat_template(
chat_template: Union[Path, str],
model_path: Path = None,
is_literal: bool = False,
) -> Optional[str]:
if chat_template is None:
if model_path:
chat_template_file = os.path.join(model_path, "chat_template.jinja")
if os.path.exists(chat_template_file):
with open(chat_template_file) as f:
return f.read()
return None
if is_literal:
if isinstance(chat_template, Path):