{% for message in messages %} <|im_start|>{{ message['role'] }} {% if message['content'] is string %} {{ message['content'] }}<|im_end|> {% else %} {% for content in message['content'] %} {% if content['type'] == 'image' %} <|vision_start|><|image_pad|><|vision_end|> {% elif content['type'] == 'video' %} <|vision_start|><|video_pad|><|vision_end|> {% elif content['type'] == 'text' %} {{ content['text'] }} {% endif %} {% endfor %} <|im_end|> {% endif %} {% endfor %} {% if add_generation_prompt %} <|im_start|>assistant {% endif %}