| {% for message in messages %}{% if loop.first and message['role'] != 'system' %}<|im_start|>system | |
| You are a helpful assistant.<|im_end|> | |
| {% endif %}<|im_start|>{{ message['role'] }} | |
| {% if message['role'] == 'assistant' %}{% generation %}{{ message['content'][0]['text'] }}<|im_end|> | |
| {% endgeneration %}{% else %}{% for content in message['content'] %}{% if content['type'] == 'image' or 'image' in content or 'image_url' in content %}<|vision_start|><|image_pad|><|vision_end|>{% elif 'text' in content %}{{ content['text'] }}{% endif %}{% endfor %}<|im_end|> | |
| {% endif %}{% endfor %}{% if add_generation_prompt %}<|im_start|>assistant | |
| {% endif %} |