|
|
|
{%- 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'] -}} |
|
{% 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 %} |
|
{{- image_token + ' |
|
' -}} |
|
{% elif content['type'] == 'video' or 'video' in content %} |
|
{{- video_token + ' |
|
' -}} |
|
{% endif %} |
|
{% endfor %} |
|
{% endif %} |
|
{{- '<|' + identifier + '_end|>' -}} |
|
{% if identifier != 'stream' %} |
|
{{- ' |
|
' -}} |
|
{% endif %} |
|
{% endfor %} |
|
{% if add_generation_prompt %} |
|
{{- '<|im_start|>assistant |
|
' -}} |
|
{% endif %} |
|
|