| {%- for message in messages %} | |
| {%- if message['content'] is string %} | |
| {{ message['content'].rstrip() }} | |
| {%- else %} | |
| {%- set ns = namespace(previous_was_image=False) %} | |
| {%- for content in message['content'] %} | |
| {%- if content['type'] == 'image' %} | |
| <image> | |
| {%- set ns.previous_was_image = True %} | |
| {%- elif content['type'] == 'text' %} | |
| {{- (' | |
| ' if ns.previous_was_image else '') + content['text'].rstrip() }} | |
| {%- set ns.previous_was_image = False %} | |
| {%- endif %} | |
| {%- endfor %} | |
| {%- endif %} | |
| {%- if not loop.last %} | |
| {%- endif %} | |
| {%- endfor %} |