Upload chat_template.jinja with huggingface_hub
Browse files- chat_template.jinja +31 -0
chat_template.jinja
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{%- set ns = namespace(system_text="") -%}
|
| 2 |
+
{%- for m in messages -%}
|
| 3 |
+
{%- if m.role == 'system' -%}
|
| 4 |
+
{%- if m.content is string -%}
|
| 5 |
+
{%- set ns.system_text = ns.system_text + m.content -%}
|
| 6 |
+
{%- else -%}
|
| 7 |
+
{%- for c in m.content -%}
|
| 8 |
+
{%- if c.type == 'text' and (c.text is defined) -%}
|
| 9 |
+
{%- set ns.system_text = ns.system_text + c.text -%}
|
| 10 |
+
{%- endif -%}
|
| 11 |
+
{%- endfor -%}
|
| 12 |
+
{%- endif -%}
|
| 13 |
+
{%- endif -%}
|
| 14 |
+
{%- endfor -%}
|
| 15 |
+
|
| 16 |
+
{%- set ns2 = namespace(audio_tokens="") -%}
|
| 17 |
+
{%- for m in messages -%}
|
| 18 |
+
{%- if m.content is not string -%}
|
| 19 |
+
{%- for c in m.content -%}
|
| 20 |
+
{%- if c.type == 'audio' or ('audio' in c) or ('audio_url' in c) -%}
|
| 21 |
+
{%- set ns2.audio_tokens = ns2.audio_tokens + "<|audio_start|><|audio_pad|><|audio_end|>" -%}
|
| 22 |
+
{%- endif -%}
|
| 23 |
+
{%- endfor -%}
|
| 24 |
+
{%- endif -%}
|
| 25 |
+
{%- endfor -%}
|
| 26 |
+
|
| 27 |
+
{{- '<|im_start|>system\n' + (ns.system_text if ns.system_text is string else '') + '<|im_end|>\n' -}}
|
| 28 |
+
{{- '<|im_start|>user\n' + ns2.audio_tokens + '<|im_end|>\n' -}}
|
| 29 |
+
{%- if add_generation_prompt -%}
|
| 30 |
+
{{- '<|im_start|>assistant\n' -}}
|
| 31 |
+
{%- endif -%}
|