Bapt120 commited on
Commit
d7aa674
·
verified ·
1 Parent(s): bee6287

Update chat_template.jinja

Browse files
Files changed (1) hide show
  1. chat_template.jinja +26 -1
chat_template.jinja CHANGED
@@ -1 +1,26 @@
1
- {% set image_count = namespace(value=0) %}{% set video_count = namespace(value=0) %}{% for message in messages %}{% if loop.first and message['role'] != 'system' %}<|im_start|>system<|im_end|>\n{% endif %}<|im_start|>{{ message['role'] }}\n{% if message['content'] is string %}{{ message['content'] }}<|im_end|>\n{% else %}{% for content in message['content'] %}{% if content['type'] == 'image' or 'image' in content or 'image_url' in content %}{% set image_count.value = image_count.value + 1 %}{% if add_vision_id %}Picture {{ image_count.value }}: {% endif %}<|image_pad|>{% elif content['type'] == 'video' or 'video' in content %}{% set video_count.value = video_count.value + 1 %}{% if add_vision_id %}Video {{ video_count.value }}: {% endif %}<|vision_start|><|video_pad|><|vision_end|>{% elif 'text' in content %}{{ content['text'] }}{% endif %}{% endfor %}<|im_end|>\n{% endif %}{% endfor %}{% if add_generation_prompt %}<|im_start|>assistant\n{% endif %}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {% set image_count = namespace(value=0) %}
2
+ {% for message in messages %}
3
+ {% if loop.first and message['role'] != 'system' %}
4
+ <|im_start|>system<|im_end|>
5
+ {% endif %}
6
+ <|im_start|>{{ message['role'] }}
7
+ {% if message['content'] is string %}
8
+ {{ message['content'] }}<|im_end|>
9
+ {% else %}
10
+ {% for content in message['content'] %}
11
+ {% if content['type'] == 'image' or 'image' in content or 'image_url' in content %}
12
+ {% set image_count.value = image_count.value + 1 %}
13
+ {% if add_vision_id %}
14
+ Picture {{ image_count.value }}:
15
+ {% endif -%}
16
+ <|image_pad|>
17
+ {%- elif 'text' in content %}
18
+ {{ content['text'] }}
19
+ {% endif %}
20
+ {% endfor %}
21
+ <|im_end|>
22
+ {% endif %}
23
+ {% endfor %}
24
+ {% if add_generation_prompt %}
25
+ <|im_start|>assistant
26
+ {% endif %}