zRzRzRzRzRzRzR commited on
Commit
c5b82b6
·
1 Parent(s): dbc994b

update template

Browse files
Files changed (2) hide show
  1. .ms_upload_cache +0 -1
  2. chat_template.jinja +12 -59
.ms_upload_cache DELETED
@@ -1 +0,0 @@
1
- {"version": 3, "repo_id": "ZhipuAI/GLM-5.3-Flash", "files": {"chat_template.jinja|1787740514.0|10644": {"hash": "34d5ee66b12fa6446cdae131c352b8f68cd85369e0e6fda115583805fada3891", "size": 10644}, "config.json|1787740514.0|68794": {"hash": "00c3ce40c92fae7f248c72a8fff3163e74bda2fe0a82d190806ad2284bcddde8", "size": 68794}, "generation_config.json|1787740514.0|194": {"hash": "230c30609ecbbb9e6583bedde8e7bdda0c6eb8fe5fad0eaeb3d1b293d751cb4f", "size": 194}, "model-00003-of-00062.safetensors|1787739040.0|5363448800": {"hash": "e9806d89bb028a51393414a5817d104ca811def3459fcff82dc37616adcdafe2", "size": 5363448800}, "model-00006-of-00062.safetensors|1787739068.0|5361790216": {"hash": "20e2cd306152f5de1e1d4ffa474e90a466d1b2ffd01c21a4182a99e263e9eaa0", "size": 5361790216}, "model-00004-of-00062.safetensors|1787739049.0|5364323736": {"hash": "faaeaf32f8b9219a3a13437bf3b5436928d39d619a82c9c375c21f995c1607c0", "size": 5364323736}, "model-00007-of-00062.safetensors|1787739078.0|5364323968": {"hash": "00b63fd168956e79228899d1a0663f045f13e6d6466c01ef93cc067aad7803da", "size": 5364323968}, "model-00005-of-00062.safetensors|1787739058.0|5363896872": {"hash": "d2124352d6cb564db9144310fff9df6ca73c7d848514ce54d0ce627bc92d4b8f", "size": 5363896872}, "model-00008-of-00062.safetensors|1787739087.0|5364323752": {"hash": "6605c4a52d76579574edfe3b7084c46d91ded3f33b678be25ee36ef724175d87", "size": 5364323752}, "model-00002-of-00062.safetensors|1787739031.0|5320647024": {"hash": "d05313aa3d972efc49076d3b7fc4ed3e827cd5648fce6fd83e8e6e4caed68a1b", "size": 5320647024}, "model-00001-of-00062.safetensors|1787739025.0|5365306688": {"hash": "fd5202d28efdd01b47557c3f59111de3b4c4c375b2709c167b9b61834663c7da", "size": 5365306688}}}
 
 
chat_template.jinja CHANGED
@@ -1,7 +1,6 @@
1
  [gMASK]<sop>
2
  {%- set effective_reasoning_effort = reasoning_effort if reasoning_effort is defined and reasoning_effort in ['low', 'high'] else 'max' -%}
3
  {%- if effective_reasoning_effort is not none -%}<|system|>Reasoning Effort: {{ effective_reasoning_effort | capitalize }}{%- endif -%}
4
- {%- set clear_thinking = clear_thinking if clear_thinking is defined else false -%}
5
  {%- if tools -%}
6
  {%- macro tool_to_json(tool) -%}
7
  {%- set ns_tool = namespace(first=true) -%}
@@ -48,24 +47,18 @@ You are provided with function signatures within <tools></tools> XML tags:
48
 
49
  For each function call, output the function name and arguments within the following XML format:
50
  <tool_call>{function-name}<arg_key>{arg-key-1}</arg_key><arg_value>{arg-value-1}</arg_value><arg_key>{arg-key-2}</arg_key><arg_value>{arg-value-2}</arg_value>...</tool_call>{%- endif -%}
51
- {%- macro emit_image() -%}<|begin_of_image|><|image|><|end_of_image|>{%- endmacro -%}
52
- {%- macro emit_video() -%}<|begin_of_video|><|video|><|end_of_video|>{%- endmacro -%}
53
- {%- macro emit_audio() -%}<|begin_of_audio|><|end_of_audio|>{%- endmacro -%}
54
  {%- macro visible_text(content) -%}
55
  {%- if content is string -%}
56
- {{- content -}}
57
  {%- elif content is iterable and content is not mapping -%}
58
  {%- for item in content -%}
59
  {%- if item is mapping and item.type == 'text' -%}
60
- {{- item.text -}}
61
  {%- elif item is string -%}
62
- {{- item -}}
63
- {%- elif item is mapping and item.type in ['image', 'image_url'] -%}
64
- {{- emit_image() -}}
65
- {%- elif item is mapping and item.type in ['video', 'video_url'] -%}
66
- {{- emit_video() -}}
67
- {%- elif item is mapping and item.type in ['audio', 'audio_url', 'input_audio'] -%}
68
- {{- emit_audio() -}}
69
  {%- endif -%}
70
  {%- endfor -%}
71
  {%- else -%}
@@ -102,33 +95,6 @@ For each function call, output the function name and arguments within the follow
102
  {%- macro is_list_of_outputs(m) -%}
103
  {%- if m.content and m.content.0.output is defined -%}1{%- endif -%}
104
  {%- endmacro -%}
105
- {%- macro has_dup_tool_result_id(lo, hi, target) -%}
106
- {%- set ns_cnt = namespace(n=0) -%}
107
- {%- for k in range(lo, hi + 1) -%}
108
- {%- set m = messages[k] -%}
109
- {%- if is_list_of_outputs(m) -%}
110
- {%- for entry in m.content -%}
111
- {%- if id_of(entry) == target -%}
112
- {%- set ns_cnt.n = ns_cnt.n + 1 -%}
113
- {%- endif -%}
114
- {%- endfor -%}
115
- {%- elif id_of(m) == target -%}
116
- {%- set ns_cnt.n = ns_cnt.n + 1 -%}
117
- {%- endif -%}
118
- {%- if ns_cnt.n > 1 -%}{%- break -%}{%- endif -%}
119
- {%- endfor -%}
120
- {%- if ns_cnt.n > 1 -%}1{%- endif -%}
121
- {%- endmacro -%}
122
- {%- macro tc_id_exists(tcs, target) -%}
123
- {%- set ns_f = namespace(found=false) -%}
124
- {%- for tc in tcs -%}
125
- {%- if id_of(tc) == target -%}
126
- {%- set ns_f.found = true -%}
127
- {%- break -%}
128
- {%- endif -%}
129
- {%- endfor -%}
130
- {%- if ns_f.found -%}1{%- endif -%}
131
- {%- endmacro -%}
132
  {%- set ns = namespace(last_user_index=-1) -%}
133
  {%- for m in messages %}
134
  {%- if m.role == 'user' %}
@@ -146,7 +112,7 @@ For each function call, output the function name and arguments within the follow
146
  {%- set reasoning_content = content.split('</think>')[0].split('<think>')[-1] %}
147
  {%- set content = content.split('</think>')[-1] %}
148
  {%- endif %}
149
- {%- if (not clear_thinking or loop.index0 > ns.last_user_index) and reasoning_content is defined -%}
150
  {{ '<think>' + reasoning_content + '</think>'}}
151
  {%- else -%}
152
  {{ '<think></think>' }}
@@ -189,34 +155,21 @@ For each function call, output the function name and arguments within the follow
189
  {%- set eid = id_of(entry) -%}
190
  {%- if not eid -%}
191
  {%- set ns_chk.can_sort = false -%}
192
- {%- elif has_dup_tool_result_id(block_start, ns_blk.end, eid) -%}
193
- {%- set ns_chk.can_sort = false -%}
194
- {%- elif not tc_id_exists(ns_a.tool_calls, eid) -%}
195
- {%- set ns_chk.can_sort = false -%}
196
  {%- endif -%}
197
  {%- endfor -%}
198
  {%- else -%}
199
  {%- set tk_id = id_of(m) -%}
200
  {%- if not tk_id -%}
201
  {%- set ns_chk.can_sort = false -%}
202
- {%- elif has_dup_tool_result_id(block_start, ns_blk.end, tk_id) -%}
203
- {%- set ns_chk.can_sort = false -%}
204
- {%- elif not tc_id_exists(ns_a.tool_calls, tk_id) -%}
205
- {%- set ns_chk.can_sort = false -%}
206
  {%- endif -%}
207
  {%- endif -%}
208
  {%- endfor -%}
209
- {%- for i in range(ns_a.tool_calls | length) -%}
210
- {%- set tc_id = id_of(ns_a.tool_calls[i]) -%}
211
  {%- if not tc_id -%}
212
  {%- set ns_chk.can_sort = false -%}
213
  {%- endif -%}
214
- {%- for j in range(i + 1, ns_a.tool_calls | length) -%}
215
- {%- if id_of(ns_a.tool_calls[j]) == tc_id -%}
216
- {%- set ns_chk.can_sort = false -%}
217
- {%- endif -%}
218
- {%- endfor -%}
219
- {%- endfor -%}
220
  {%- endif -%}
221
  {%- if ns_chk.can_sort -%}
222
  {%- for tc in ns_a.tool_calls -%}
@@ -233,8 +186,8 @@ For each function call, output the function name and arguments within the follow
233
  {{- tool_response(visible_text(entry.output)) -}}
234
  {%- endif -%}
235
  {%- endif -%}
236
- {%- endfor -%}
237
- {%- else -%}
238
  {%- set tk_id = id_of(m) -%}
239
  {%- if tk_id == tc_id -%}
240
  {{- render_tool_response(m) -}}
 
1
  [gMASK]<sop>
2
  {%- set effective_reasoning_effort = reasoning_effort if reasoning_effort is defined and reasoning_effort in ['low', 'high'] else 'max' -%}
3
  {%- if effective_reasoning_effort is not none -%}<|system|>Reasoning Effort: {{ effective_reasoning_effort | capitalize }}{%- endif -%}
 
4
  {%- if tools -%}
5
  {%- macro tool_to_json(tool) -%}
6
  {%- set ns_tool = namespace(first=true) -%}
 
47
 
48
  For each function call, output the function name and arguments within the following XML format:
49
  <tool_call>{function-name}<arg_key>{arg-key-1}</arg_key><arg_value>{arg-value-1}</arg_value><arg_key>{arg-key-2}</arg_key><arg_value>{arg-value-2}</arg_value>...</tool_call>{%- endif -%}
 
 
 
50
  {%- macro visible_text(content) -%}
51
  {%- if content is string -%}
52
+ {{- content }}
53
  {%- elif content is iterable and content is not mapping -%}
54
  {%- for item in content -%}
55
  {%- if item is mapping and item.type == 'text' -%}
56
+ {{- item.text }}
57
  {%- elif item is string -%}
58
+ {{- item }}
59
+ {%- elif item is mapping and item.type in ['image', 'image_url', 'video', 'video_url', 'audio', 'audio_url', 'input_audio'] -%}
60
+ {%- set media_type = item.type | replace('_url', '') | replace('input_', '') -%}
61
+ {{- "<reminder>You are unable to process this " ~ media_type ~ " because you don't have multi-modal input ability. Try different methods.</reminder>" }}
 
 
 
62
  {%- endif -%}
63
  {%- endfor -%}
64
  {%- else -%}
 
95
  {%- macro is_list_of_outputs(m) -%}
96
  {%- if m.content and m.content.0.output is defined -%}1{%- endif -%}
97
  {%- endmacro -%}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
98
  {%- set ns = namespace(last_user_index=-1) -%}
99
  {%- for m in messages %}
100
  {%- if m.role == 'user' %}
 
112
  {%- set reasoning_content = content.split('</think>')[0].split('<think>')[-1] %}
113
  {%- set content = content.split('</think>')[-1] %}
114
  {%- endif %}
115
+ {%- if ((clear_thinking is defined and not clear_thinking) or loop.index0 > ns.last_user_index) and reasoning_content is defined -%}
116
  {{ '<think>' + reasoning_content + '</think>'}}
117
  {%- else -%}
118
  {{ '<think></think>' }}
 
155
  {%- set eid = id_of(entry) -%}
156
  {%- if not eid -%}
157
  {%- set ns_chk.can_sort = false -%}
 
 
 
 
158
  {%- endif -%}
159
  {%- endfor -%}
160
  {%- else -%}
161
  {%- set tk_id = id_of(m) -%}
162
  {%- if not tk_id -%}
163
  {%- set ns_chk.can_sort = false -%}
 
 
 
 
164
  {%- endif -%}
165
  {%- endif -%}
166
  {%- endfor -%}
167
+ {%- for tc in ns_a.tool_calls -%}
168
+ {%- set tc_id = id_of(tc) -%}
169
  {%- if not tc_id -%}
170
  {%- set ns_chk.can_sort = false -%}
171
  {%- endif -%}
172
+ {%- endfor -%}
 
 
 
 
 
173
  {%- endif -%}
174
  {%- if ns_chk.can_sort -%}
175
  {%- for tc in ns_a.tool_calls -%}
 
186
  {{- tool_response(visible_text(entry.output)) -}}
187
  {%- endif -%}
188
  {%- endif -%}
189
+ {%- endfor -%}
190
+ {%- else -%}
191
  {%- set tk_id = id_of(m) -%}
192
  {%- if tk_id == tc_id -%}
193
  {{- render_tool_response(m) -}}