@@ -2796,36 +2796,35 @@ class Llava15ChatHandler:
27962796
27972797 CHAT_FORMAT = (
27982798 "{% for message in messages %}"
2799- "{% if message.role == 'system' %}"
2800- "{{ message.content }}"
2801- "{% endif %}"
2802- "{% if message.role == 'user' %}"
2803- "{% if message.content is string %}"
2804- "\n USER: {{ message.content }}"
2805- "{% endif %}"
2806- "{% if message.content is iterable %}"
2807- "\n USER: "
2808- "{% for content in message.content %}"
2809- "{% if content.type == 'image_url' and content.image_url is string %}"
2810- "{{ content.image_url }}"
2811- "{% endif %}"
2812- "{% if content.type == 'image_url' and content.image_url is mapping %}"
2813- "{{ content.image_url.url }}"
2814- "{% endif %}"
2815- "{% endfor %}"
2816- "{% for content in message.content %}"
2817- "{% if content.type == 'text' %}"
2818- "{{ content.text }}"
2819- "{% endif %}"
2820- "{% endfor %}"
2821- "{% endif %}"
2822- "{% endif %}"
2823- "{% if message.role == 'assistant' and message.content is not none %}"
2824- "\n ASSISTANT: {{ message.content }}"
2825- "{% endif %}"
2799+ "{% if message.role == 'system' %}"
2800+ "{{ message.content }}"
2801+ "{% endif %}"
2802+
2803+ "{% if message.role == 'user' %}"
2804+ "{% if message.content is string %}"
2805+ "\n USER: {{ message.content }}"
2806+ "{% elif message.content is iterable %}"
2807+ "\n USER: "
2808+ "{% for content in message.content %}"
2809+ "{% if content.type == 'image_url' %}"
2810+ "{{ content.image_url if content.image_url is string else content.image_url.url }}"
2811+ "{% endif %}"
2812+ "{% endfor %}"
2813+ "{% for content in message.content %}"
2814+ "{% if content.type == 'text' %}"
2815+ "{{ content.text }}"
2816+ "{% endif %}"
2817+ "{% endfor %}"
2818+ "{% endif %}"
2819+ "{% endif %}"
2820+
2821+ "{% if message.role == 'assistant' and message.content is not none %}"
2822+ "\n ASSISTANT: {{ message.content }}"
2823+ "{% endif %}"
28262824 "{% endfor %}"
2825+
28272826 "{% if add_generation_prompt %}"
2828- "\n ASSISTANT: "
2827+ "\n ASSISTANT: "
28292828 "{% endif %}"
28302829 )
28312830
0 commit comments