File size: 714 Bytes
c588694
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
{%- for message in messages -%}
{%- set ns = namespace(has_image=false, text='') -%}
{%- if message['content'] is string -%}
{%- set ns.text = message['content'] -%}
{%- else -%}
{%- for item in message['content'] -%}
{%- if 'image' in item or 'image_url' in item or item.type == 'image' -%}
{%- set ns.has_image = true -%}
{%- elif 'text' in item -%}
{%- set ns.text = ns.text + item.text -%}
{%- endif -%}
{%- endfor -%}
{%- endif -%}
{%- if ns.has_image -%}
{{- '<|im_start|>user\n<|vision_start|><|image_pad|><|vision_end|>Describe the image.<|im_end|><|endoftext|>' -}}
{%- else -%}
{{- '<|im_start|>user\nQuery: ' + ns.text + '<|endoftext|>' * 10 + '<|im_end|><|endoftext|>' -}}
{%- endif -%}
{%- endfor -%}