Update chat_template.jinja
Browse files- chat_template.jinja +22 -22
chat_template.jinja
CHANGED
|
@@ -1,23 +1,23 @@
|
|
| 1 |
-
{%- macro visible_text(content) %}
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
{%- endmacro %}
|
| 14 |
|
| 15 |
-
{%- for message in messages %}
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
{%- endfor %}
|
| 21 |
-
{%- if add_generation_prompt %}
|
| 22 |
-
|
| 23 |
-
{%- endif %}
|
|
|
|
| 1 |
+
{%- macro visible_text(content) -%}
|
| 2 |
+
{%- if content is iterable and content is not mapping -%}
|
| 3 |
+
{%- for item in content -%}
|
| 4 |
+
{%- if item is mapping and item.type == "text" -%}
|
| 5 |
+
{{- item.text -}}
|
| 6 |
+
{%- elif item is string -%}
|
| 7 |
+
{{- item -}}
|
| 8 |
+
{%- endif -%}
|
| 9 |
+
{%- endfor -%}
|
| 10 |
+
{%- else -%}
|
| 11 |
+
{{- content -}}
|
| 12 |
+
{%- endif -%}
|
| 13 |
+
{%- endmacro -%}
|
| 14 |
|
| 15 |
+
{%- for message in messages -%}
|
| 16 |
+
{%- if loop.first and messages[0].role != "system" -%}
|
| 17 |
+
{{- "<|im_start|>system\nYou are Ami, a helpful, friendly and empathetic AI chatbot.<|im_end|>\n" -}}
|
| 18 |
+
{%- endif -%}
|
| 19 |
+
{{- "<|im_start|>" + message.role + "\n" + visible_text(message.content) + "<|im_end|>\n" -}}
|
| 20 |
+
{%- endfor -%}
|
| 21 |
+
{%- if add_generation_prompt -%}
|
| 22 |
+
{{- "<|im_start|>assistant\n" -}}
|
| 23 |
+
{%- endif -%}
|