SamChen567's picture
Add files using upload-large-folder tool
41be407 verified
Raw History Blame Contribute Delete
2.04 kB
{%- set identifier = 'im' %}
{% for message in messages %}
{% if add_system_prompt and loop.first and message['role'] != 'system' %}
{{- '<|im_start|>system
You are VideoLLaMA3 created by Alibaba DAMO Academy, a helpful assistant to help people understand images and videos.<|im_end|>
' -}}
{% endif %}
{% if message['role'] == 'stream' %}
{% set identifier = 'stream' %}
{% else %}
{% set identifier = 'im' %}
{% endif %}
{{- '<|' + identifier + '_start|>' + message['role'] + '
' -}}
{% if message['content'] is string %}
{{- message['content'] + '<|' + identifier + '_end|>
' -}}
{% else %}
{% for content in message['content'] %}
{% if content is string %}
{{- content -}}
{% elif content['type'] == 'text' or 'text' in content %}
{{- content['text'] -}}
{% elif content['type'] == 'image' or 'image' in content %}
{% if 'timestamp' in content %}
{{- 'Time ' + content['timestamp'] | round(1) | string + 's: ' -}}
{% endif %}
{{- '<image>
' -}}
{% elif content['type'] == 'video' or 'video' in content %}
{% for i in range(content['num_frames']) %}
{% if 'timestamps' in content %}
{{- 'Time ' + content['timestamps'][i] | round(1) | string + 's:' -}}
{% endif %}
{% if i < content['num_frames'] - 1 %}
{{- '<image>,' -}}
{% else %}
{{- '<image>
' -}}
{% endif %}
{% endfor %}
{% endif %}
{% endfor %}
{% if identifier == 'stream' %}
{{- '<|' + identifier + '_end|>' -}}
{% else %}
{{- '<|' + identifier + '_end|>
' -}}
{% endif %}
{% endif %}
{% endfor %}
{% if add_generation_prompt %}
{{- '<|im_start|>assistant
' -}}
{% endif %}