{%- for message in messages -%} {%- set images = message['content'] | selectattr('type', 'equalto', 'image') | list -%} {%- set texts = message['content'] | selectattr('type', 'equalto', 'text') | map(attribute='text') | list -%} {%- if images -%} {%- for _ in images -%}{{- '' -}}{%- endfor -%} {{- texts[0] if texts else 'Describe the image.' -}} {%- else -%} {{ bos_token }}Question: {{ texts[0] }}{{ '' * 5 }} {% endif %} {% endfor %}