File size: 1,221 Bytes
915ce50
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41

{%- 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['type'] == 'text' %}
                {{- content['text'] -}}
            {% elif content['type'] == 'image' %}
                {{- '<|image_pad|>' + '
' -}}
            {% elif content['type'] == 'video' %}
                {{- '<|video_pad|>' + '
' -}}
            {% endif %}
        {% endfor %}
    {% endif %}
    {{- '<|' + identifier + '_end|>' -}}
    {% if identifier != 'stream' %}
        {{- '
' -}}
    {% endif %}
{% endfor %}
{% if add_generation_prompt %}
    {{- '<|im_start|>assistant
' -}}
{% endif %}