GLM-ASR-Nano-2512 / chat_template.jinja
eustlb's picture
eustlb HF Staff
Upload processor
bda9ff9 verified
raw
history blame contribute delete
851 Bytes
{%- macro to_text(content) -%}
{%- if content is string -%}
{{- content -}}
{%- elif content is iterable and content is not mapping -%}
{%- for item in content -%}
{%- if item is mapping and item.type == 'text' and item.text is defined -%}
{{- item.text -}}
{%- elif item is mapping and (item.type == 'audio' or 'audio' in item) -%}
<|begin_of_audio|><|pad|><|end_of_audio|><|user|>
{% elif item is string -%}
{{- item -}}
{%- endif -%}
{%- endfor -%}
{%- else -%}
{{- content -}}
{%- endif -%}
{%- endmacro -%}
{%- for m in messages -%}
{%- if m.role == 'system' -%}
<|system|>
{{ to_text(m.content) | trim }}
{%- elif m.role == 'user' -%}
<|user|>
{{ to_text(m.content) | trim }}
{%- elif m.role == 'assistant' -%}
<|assistant|>
{{ to_text(m.content) | trim }}
{%- endif -%}
{%- endfor -%}
{%- if add_generation_prompt -%}
<|assistant|>
{% endif -%}