{{ bos_token }}{% for message in messages %}{% set role = message['role'] %}{% if role == 'assistant' %}{% set role = 'model' %}{% endif %}<|turn>{{ role }} {% if message['content'] is string %}{{ message['content'] | trim }}{% else %}{% for item in message['content'] %}{% if item['type'] == 'text' %}{{ item['text'] | trim }}{% elif item['type'] == 'image' %}<|image|>{% elif item['type'] == 'video' %}<|video|>{% endif %}{% endfor %}{% endif %} {% endfor %}{% if add_generation_prompt %}<|turn>model {% endif %}