Update chat_template.jinja
#12
by jp1924 - opened
- chat_template.jinja +14 -23
chat_template.jinja
CHANGED
|
@@ -26,12 +26,14 @@
|
|
| 26 |
{{- '<|im_start|>system\n' + messages[0].content + '<|im_end|>\n' }}
|
| 27 |
{%- endif %}
|
| 28 |
{%- endif %}
|
|
|
|
| 29 |
{%- set ns = namespace(last_user_index=-1) %}
|
| 30 |
{%- for m in messages %}
|
| 31 |
{%- if m.role == 'user' %}
|
| 32 |
{%- set ns.last_user_index = loop.index0 %}
|
| 33 |
{%- endif %}
|
| 34 |
{%- endfor %}
|
|
|
|
| 35 |
{%- for message in messages %}
|
| 36 |
{%- set content = message.get('content', '') or '' %}
|
| 37 |
{%- if (message.role == 'system' and not loop.first) %}
|
|
@@ -45,28 +47,17 @@
|
|
| 45 |
{%- if not loop.first %}
|
| 46 |
{{- '\n' }}
|
| 47 |
{%- endif %}
|
| 48 |
-
{%- if content['type']
|
| 49 |
-
{%- set
|
| 50 |
-
{%- set
|
| 51 |
-
{
|
| 52 |
-
{
|
| 53 |
-
{
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
{
|
| 58 |
-
{
|
| 59 |
-
{%- set video_id = 'video_%02d' % ns_vid.count %}
|
| 60 |
-
{%- set ns_vid.count = ns_vid.count + 1 %}
|
| 61 |
-
{{- '<|mime_start|>{"id": "' + video_id + '", "type": "video/mp4", "filename": "video.mp4"}<|mime_end|>\n' }}
|
| 62 |
-
{{- '<|video_aux_start|>다음 중 video_duration은 비디오 길이 정보입니다. 참고하여 답변하세요. {"video_duration": "<|video_meta_duration|>"}<|video_aux_end|>\n'}}
|
| 63 |
-
{{- '<|video_start|><|VIDEO_PAD|><|video_end|>\n'}}
|
| 64 |
-
{%- else %}
|
| 65 |
-
{%- set image_id = 'image_%02d' % ns_img.count %}
|
| 66 |
-
{%- set ns_img.count = ns_img.count + 1 %}
|
| 67 |
-
{{- '<|mime_start|>{"id": "' + image_id + '", "type": "image/jpeg", "filename": "image.jpg"}<|mime_end|>\n' }}
|
| 68 |
-
{{- '<|image_start|><|IMAGE_PAD|><|image_end|>' }}
|
| 69 |
-
{%- endif %}
|
| 70 |
{%- elif content['type'] == 'text' %}
|
| 71 |
{{- content['text'] }}
|
| 72 |
{%- endif %}
|
|
@@ -132,4 +123,4 @@
|
|
| 132 |
{%- else %}
|
| 133 |
{{- '<|im_start|>assistant\n<think>\n\n</think>\n\n' }}
|
| 134 |
{%- endif %}
|
| 135 |
-
{%- endif %}
|
|
|
|
| 26 |
{{- '<|im_start|>system\n' + messages[0].content + '<|im_end|>\n' }}
|
| 27 |
{%- endif %}
|
| 28 |
{%- endif %}
|
| 29 |
+
|
| 30 |
{%- set ns = namespace(last_user_index=-1) %}
|
| 31 |
{%- for m in messages %}
|
| 32 |
{%- if m.role == 'user' %}
|
| 33 |
{%- set ns.last_user_index = loop.index0 %}
|
| 34 |
{%- endif %}
|
| 35 |
{%- endfor %}
|
| 36 |
+
|
| 37 |
{%- for message in messages %}
|
| 38 |
{%- set content = message.get('content', '') or '' %}
|
| 39 |
{%- if (message.role == 'system' and not loop.first) %}
|
|
|
|
| 47 |
{%- if not loop.first %}
|
| 48 |
{{- '\n' }}
|
| 49 |
{%- endif %}
|
| 50 |
+
{%- if content['type'] in ['video_url', 'video'] %}
|
| 51 |
+
{%- set video_id = 'video_%02d' % ns_vid.count %}
|
| 52 |
+
{%- set ns_vid.count = ns_vid.count + 1 %}
|
| 53 |
+
{{- '<|mime_start|>{"id": "' + video_id + '", "type": "video/mp4", "filename": "video.mp4"}<|mime_end|>\n' }}
|
| 54 |
+
{{- '<|video_aux_start|>다음 중 video_duration은 비디오 길이 정보입니다. 참고하여 답변하세요. {"video_duration": "<|video_meta_duration|>"}<|video_aux_end|>\n'}}
|
| 55 |
+
{{- '<|video_start|><|VIDEO_PAD|><|video_end|>' }}
|
| 56 |
+
{%- elif content['type'] in ['image_url', 'image'] %}
|
| 57 |
+
{%- set image_id = 'image_%02d' % ns_img.count %}
|
| 58 |
+
{%- set ns_img.count = ns_img.count + 1 %}
|
| 59 |
+
{{- '<|mime_start|>{"id": "' + image_id + '", "type": "image/jpeg", "filename": "image.jpg"}<|mime_end|>\n' }}
|
| 60 |
+
{{- '<|image_start|><|IMAGE_PAD|><|image_end|>' }}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
{%- elif content['type'] == 'text' %}
|
| 62 |
{{- content['text'] }}
|
| 63 |
{%- endif %}
|
|
|
|
| 123 |
{%- else %}
|
| 124 |
{{- '<|im_start|>assistant\n<think>\n\n</think>\n\n' }}
|
| 125 |
{%- endif %}
|
| 126 |
+
{%- endif %}
|