Skip to content

Commit

Permalink
Add test for exception on empty rendered chat template
Browse files Browse the repository at this point in the history
  • Loading branch information
yatarkan committed Jan 17, 2025
1 parent 087faa2 commit 49951a5
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tests/python_tests/test_tokenizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,12 @@ def test_apply_chat_template(model_tmp_path, chat_config: Tuple[str, Dict]):
print(f'ov_genai out: {ov_full_history_str}')
assert ov_full_history_str == hf_full_history_str

# Test throwing exception for empty rendered chat template
# Example: Qwen2-VL chat template
chat_template_for_empty_output = "{% if messages is string %}{{ messages }}{% else %}{% for content in messages %}{% if content['type'] == 'image' or 'image' in content or 'image_url' in content %}<|vision_start|><|image_pad|><|vision_end|>{% elif content['type'] == 'video' or 'video' in content %}<|vision_start|><|video_pad|><|vision_end|>{% elif 'text' in content %}{{ content['text'] }}{% endif %}{% endfor %}{% endif %}"
with pytest.raises(Exception):
ov_tokenizer.apply_chat_template(conversation, chat_template=chat_template_for_empty_output)


@pytest.mark.precommit
@pytest.mark.nightly
Expand Down

0 comments on commit 49951a5

Please sign in to comment.