SmolVLM2-500M-Video-Instruct / chat_template.jinja
mjschock's picture
Add base model with custom chat template
0b2bf25 verified
<|im_start|>{% for message in messages %}{% if message['role'] == 'system' %}System: {% for line in message['content'] %}{% if line['type'] == 'text' %}{{line['text']}}{% endif %}{% endfor %}<|im_end|>
{% elif message['role'] == 'tool' %}Tool: {% for line in message['content'] %}{% if line['type'] == 'text' %}{{line['text']}}{% endif %}{% endfor %}<end_of_utterance>
{% elif message['role'] == 'assistant' and message.get('tool_calls') %}{{message['role'] | capitalize}}: {% for line in message['content'] %}{% if line['type'] == 'text' %}{{line['text']}}{% elif line['type'] == 'image' %}{{ '<image>' }}{% endif %}{% endfor %}{% if message['tool_calls'] %}<tool_calls>
{% for tool_call in message['tool_calls'] %}{"id": "{{tool_call['id']}}", "type": "{{tool_call['type']}}", "function": {"name": "{{tool_call['function']['name']}}", "arguments": "{{tool_call['function']['arguments']}}"}}
{% endfor %}</tool_calls>{% endif %}<end_of_utterance>
{% else %}{{message['role'] | capitalize}}{% if message['content'][0]['type'] == 'image' %}{{':'}}{% else %}{{': '}}{% endif %}{% if message['role'] == 'assistant' %}{% generation %}{% for line in message['content'] %}{% if line['type'] == 'text' %}{{line['text']}}{% elif line['type'] == 'image' %}{{ '<image>' }}{% endif %}{% endfor %}{% endgeneration %}{% else %}{% for line in message['content'] %}{% if line['type'] == 'text' %}{{line['text']}}{% elif line['type'] == 'image' %}{{ '<image>' }}{% endif %}{% endfor %}{% endif %}<end_of_utterance>
{% endif %}{% endfor %}{% if add_generation_prompt %}{{ 'Assistant:' }}{% endif %}