CoolFace
Modelpublic

RedHatAI/GLM-4.6-quantized.w8a8

sourceHugging Faceupdated 7mo agoView on Hugging Face
0likes29downloads
chat_template.jinja103 linesDownload Raw Back to root
1[gMASK]<sop>2{%- if tools -%}3<|system|>4# Tools5 6You may call one or more functions to assist with the user query.7 8You are provided with function signatures within <tools></tools> XML tags:9<tools>10{% for tool in tools %}11{{ tool | tojson(ensure_ascii=False) }}12{% endfor %}13</tools>14 15For each function call, output the function name and arguments within the following XML format:16<tool_call>{function-name}17<arg_key>{arg-key-1}</arg_key>18<arg_value>{arg-value-1}</arg_value>19<arg_key>{arg-key-2}</arg_key>20<arg_value>{arg-value-2}</arg_value>21...22</tool_call>{%- endif -%}23{%- macro visible_text(content) -%}24    {%- if content is string -%}25        {{- content }}26    {%- elif content is iterable and content is not mapping -%}27        {%- for item in content -%}28            {%- if item is mapping and item.type == 'text' -%}29                {{- item.text }}30            {%- elif item is string -%}31                {{- item }}32            {%- endif -%}33        {%- endfor -%}34    {%- else -%}35        {{- content }}36    {%- endif -%}37{%- endmacro -%}38{%- set ns = namespace(last_user_index=-1) %}39{%- for m in messages %}40    {%- if m.role == 'user' %}41        {% set ns.last_user_index = loop.index0 -%}42    {%- endif %}43{%- endfor %}44{% for m in messages %}45{%- if m.role == 'user' -%}<|user|>46{{ visible_text(m.content) }}47{{- '/nothink' if (enable_thinking is defined and not enable_thinking and not visible_text(m.content).endswith("/nothink")) else '' -}}48{%- elif m.role == 'assistant' -%}49<|assistant|>50{%- set reasoning_content = '' %}51{%- set content = visible_text(m.content) %}52{%- if m.reasoning_content is string %}53    {%- set reasoning_content = m.reasoning_content %}54{%- else %}55    {%- if '</think>' in content %}56        {%- set reasoning_content = content.split('</think>')[0].rstrip('\n').split('<think>')[-1].lstrip('\n') %}57        {%- set content = content.split('</think>')[-1].lstrip('\n') %}58    {%- endif %}59{%- endif %}60{%- if loop.index0 > ns.last_user_index and reasoning_content -%}61{{ '\n<think>' + reasoning_content.strip() +  '</think>'}}62{%- else -%}63{{ '\n<think></think>' }}64{%- endif -%}65{%- if content.strip() -%}66{{ '\n' + content.strip() }}67{%- endif -%}68{% if m.tool_calls %}69{% for tc in m.tool_calls %}70{%- if tc.function %}71    {%- set tc = tc.function %}72{%- endif %}73{{ '\n<tool_call>' + tc.name }}74{% set _args = tc.arguments %}75{% for k, v in _args.items() %}76<arg_key>{{ k }}</arg_key>77<arg_value>{{ v | tojson(ensure_ascii=False) if v is not string else v }}</arg_value>78{% endfor %}79</tool_call>{% endfor %}80{% endif %}81{%- elif m.role == 'tool' -%}82{%- if m.content is string -%}83{%- if loop.first or (messages[loop.index0 - 1].role != "tool") %}84    {{- '<|observation|>' }}85{%- endif %}86{{- '\n<tool_response>\n' }}87{{- m.content }}88{{- '\n</tool_response>' }}89{%- else -%}90<|observation|>{% for tr in m.content %}91 92<tool_response>93{{ tr.output if tr.output is defined else tr }}94</tool_response>{% endfor -%}95{% endif -%}96{%- elif m.role == 'system' -%}97<|system|>98{{ visible_text(m.content) }}99{%- endif -%}100{%- endfor -%}101{%- if add_generation_prompt -%}102    <|assistant|>{{- '\n<think></think>' if (enable_thinking is defined and not enable_thinking) else '' -}}103{%- endif -%}