@@ -2175,19 +2175,25 @@ class Llava15ChatHandler:
2175
2175
"{% if message.role == 'user' %}"
2176
2176
"{% if message.content is string %}"
2177
2177
"\n USER: {{ message.content }}"
2178
- "{% elif message.content is iterable %}"
2178
+ "{% endif %}"
2179
+ "{% if message.content is iterable %}"
2179
2180
"\n USER: "
2181
+
2180
2182
"{% for content in message.content %}"
2181
- "{% if content.type == 'text' %}"
2182
- "{{ content.text }}"
2183
- "{% endif %}"
2184
2183
"{% if content.type == 'image_url' and content.image_url is string %}"
2185
2184
"{{ content.image_url }}"
2186
2185
"{% endif %}"
2187
2186
"{% if content.type == 'image_url' and content.image_url is mapping %}"
2188
2187
"{{ content.image_url.url }}"
2189
2188
"{% endif %}"
2190
2189
"{% endfor %}"
2190
+
2191
+ "{% for content in message.content %}"
2192
+ "{% if content.type == 'text' %}"
2193
+ "{{ content.text }}"
2194
+ "{% endif %}"
2195
+ "{% endfor %}"
2196
+
2191
2197
"{% endif %}"
2192
2198
"{% endif %}"
2193
2199
"{% if message.role == 'assistant' and message.content is not none %}"
@@ -2575,14 +2581,22 @@ class ObsidianChatHandler(Llava15ChatHandler):
2575
2581
"{{ message.content }}"
2576
2582
"{% endif %}"
2577
2583
"{% if message.content is iterable %}"
2584
+
2585
+ "{% for content in message.content %}"
2586
+ "{% if content.type == 'image_url' and content.image_url is string %}"
2587
+ "{{ content.image_url }}"
2588
+ "{% endif %}"
2589
+ "{% if content.type == 'image_url' and content.image_url is mapping %}"
2590
+ "{{ content.image_url.url }}"
2591
+ "{% endif %}"
2592
+ "{% endfor %}"
2593
+
2578
2594
"{% for content in message.content %}"
2579
2595
"{% if content.type == 'text' %}"
2580
2596
"{{ content.text }}"
2581
2597
"{% endif %}"
2582
- "{% if content.type == 'image_url' %}"
2583
- "{{ content.image_url }}"
2584
- "{% endif %}"
2585
2598
"{% endfor %}"
2599
+
2586
2600
"{% endif %}"
2587
2601
"###\n "
2588
2602
"{% endif %}"
@@ -2606,9 +2620,9 @@ class MoondreamChatHandler(Llava15ChatHandler):
2606
2620
"{% for message in messages %}"
2607
2621
"{% if message.role == 'user' %}"
2608
2622
"{% if message.content is iterable %}"
2609
- "{% for content in message.content %}"
2610
2623
2611
2624
# <image>
2625
+ "{% for content in message.content %}"
2612
2626
"{% if content.type == 'image_url' %}"
2613
2627
"{% if content.image_url is string %}"
2614
2628
"{{ content.image_url }}\n \n "
@@ -2617,12 +2631,15 @@ class MoondreamChatHandler(Llava15ChatHandler):
2617
2631
"{{ content.image_url.url }}\n \n "
2618
2632
"{% endif %}"
2619
2633
"{% endif %}"
2634
+ "{% endfor %}"
2620
2635
2621
2636
# Question:
2637
+ "{% for content in message.content %}"
2622
2638
"{% if content.type == 'text' %}"
2623
2639
"Question: {{ content.text }}\n \n "
2624
2640
"{% endif %}"
2625
2641
"{% endfor %}"
2642
+
2626
2643
"{% endif %}"
2627
2644
2628
2645
# Question:
@@ -2657,9 +2674,9 @@ class Llava16ChatHandler(Llava15ChatHandler):
2657
2674
"{% endif %}"
2658
2675
"{% if message.role == 'user' %}"
2659
2676
"{% if message.content is iterable %}"
2660
- "{% for content in message.content %}"
2661
2677
2662
2678
# <image>
2679
+ "{% for content in message.content %}"
2663
2680
"{% if content.type == 'image_url' %}"
2664
2681
"{% if content.image_url is string %}"
2665
2682
"{{ content.image_url }}\n "
@@ -2668,12 +2685,15 @@ class Llava16ChatHandler(Llava15ChatHandler):
2668
2685
"{{ content.image_url.url }}\n "
2669
2686
"{% endif %}"
2670
2687
"{% endif %}"
2688
+ "{% endfor %}"
2671
2689
2672
2690
# Question:
2691
+ "{% for content in message.content %}"
2673
2692
"{% if content.type == 'text' %}"
2674
2693
"{{ content.text }}"
2675
2694
"{% endif %}"
2676
2695
"{% endfor %}"
2696
+
2677
2697
"{% endif %}"
2678
2698
2679
2699
# Question:
@@ -2719,14 +2739,22 @@ class NanoLlavaChatHandler(Llava15ChatHandler):
2719
2739
"{{ message.content }}"
2720
2740
"{% endif %}"
2721
2741
"{% if message.content is iterable %}"
2742
+
2743
+ "{% for content in message.content %}"
2744
+ "{% if content.type == 'image_url' and content.image_url is string %}"
2745
+ "{{ content.image_url }}"
2746
+ "{% endif %}"
2747
+ "{% if content.type == 'image_url' and content.image_url is mapping %}"
2748
+ "{{ content.image_url.url }}"
2749
+ "{% endif %}"
2750
+ "{% endfor %}"
2751
+
2722
2752
"{% for content in message.content %}"
2723
2753
"{% if content.type == 'text' %}"
2724
2754
"{{ content.text }}"
2725
2755
"{% endif %}"
2726
- "{% if content.type == 'image_url' %}"
2727
- "{{ content.image_url }}"
2728
- "{% endif %}"
2729
2756
"{% endfor %}"
2757
+
2730
2758
"{% endif %}"
2731
2759
"<|im_end|>"
2732
2760
"{% endif %}"
0 commit comments