diff --git a/src/mobius/integrations/ort_genai/auto_export.py b/src/mobius/integrations/ort_genai/auto_export.py index 71f79510..4efb9509 100644 --- a/src/mobius/integrations/ort_genai/auto_export.py +++ b/src/mobius/integrations/ort_genai/auto_export.py @@ -88,6 +88,7 @@ def _copy_tokenizer_files( "added_tokens.json", "merges.txt", # BPE "vocab.json", # BPE + "chat_template.jinja", # Chat template for ORT GenAI ] copied: list[str] = [] for filename in tokenizer_files: @@ -127,6 +128,7 @@ def _copy_tokenizer_files_from_local( "added_tokens.json", "merges.txt", # BPE "vocab.json", # BPE + "chat_template.jinja", # Chat template for ORT GenAI ] copied: list[str] = [] for filename in tokenizer_files: diff --git a/src/mobius/integrations/ort_genai/auto_export_test.py b/src/mobius/integrations/ort_genai/auto_export_test.py index c7abce3c..479edb68 100644 --- a/src/mobius/integrations/ort_genai/auto_export_test.py +++ b/src/mobius/integrations/ort_genai/auto_export_test.py @@ -63,6 +63,7 @@ def test_copies_available_files(self, tmp_path): fake_src = tmp_path / "src" fake_src.mkdir() (fake_src / "tokenizer.json").write_text('{"test": true}') + (fake_src / "chat_template.jinja").write_text("{{ messages }}") with mock.patch("huggingface_hub.hf_hub_download") as mock_dl: mock_dl.side_effect = lambda model_id, filename: ( @@ -77,6 +78,8 @@ def test_copies_available_files(self, tmp_path): assert "tokenizer.json" in copied assert (dst / "tokenizer.json").exists() + assert "chat_template.jinja" in copied + assert (dst / "chat_template.jinja").exists() class TestCopyTokenizerFilesFromLocal: @@ -88,14 +91,19 @@ def test_copies_present_files(self, tmp_path): src.mkdir() (src / "tokenizer.json").write_text('{"test": true}') (src / "tokenizer_config.json").write_text('{"model_type": "llama"}') + (src / "chat_template.jinja").write_text("{{ messages }}") dst = tmp_path / "output" dst.mkdir() copied = _copy_tokenizer_files_from_local(str(src), str(dst)) - assert set(copied) == {"tokenizer.json", "tokenizer_config.json"} + assert set(copied) == { + "tokenizer.json", + "tokenizer_config.json", + "chat_template.jinja", + } assert (dst / "tokenizer.json").read_text() == '{"test": true}' - assert (dst / "tokenizer_config.json").read_text() == '{"model_type": "llama"}' + assert (dst / "chat_template.jinja").read_text() == "{{ messages }}" def test_skips_absent_files(self, tmp_path): """Files not present in the source directory are silently skipped."""