molmo-hf-7B-D / chat_template.json
Molbap's picture
Molbap HF staff
Upload processor
2a5ac63 verified
raw
history blame
665 Bytes
{
"chat_template": "{% for message in messages %}{%- if (loop.index % 2 == 1 and message['role'] != 'user') or (loop.index % 2 == 0 and message['role'].lower() != 'assistant') -%}{{ raise_exception('Conversation roles must alternate user/assistant/user/assistant/...') }}{%- endif -%}{{ message['role'].capitalize() + ': '}}{% if message['content'] is string %}{{ message['content'] + ' ' }}{% else %}{% for content in message['content'] %}{% if content['type'] == 'image' %}{{ '<image> ' }}{% elif content['type'] == 'text' %}{{ content['text'] + ' ' }}{% endif %}{% endfor %}{% endif %}{% endfor %}{% if add_generation_prompt %}{{ 'Assistant:' }}{% endif %}"
}