chat template: early break in tool result reordering check
#3
by mmangkad - opened
- chat_template.jinja +6 -2
chat_template.jinja
CHANGED
|
@@ -62,7 +62,7 @@ For each function call, output the function name and arguments within the follow
|
|
| 62 |
{{- "<reminder>You are unable to process this " ~ media_type ~ " because you don't have multi-modal input ability. Try different methods.</reminder>" }}
|
| 63 |
{%- endif -%}
|
| 64 |
{%- endfor -%}
|
| 65 |
-
{%-
|
| 66 |
{{- content }}
|
| 67 |
{%- endif -%}
|
| 68 |
{%- endmacro -%}
|
|
@@ -177,9 +177,11 @@ For each function call, output the function name and arguments within the follow
|
|
| 177 |
{%- set ns_chk.can_sort = false -%}
|
| 178 |
{%- else -%}
|
| 179 |
{%- for k in range(block_start, ns_blk.end + 1) -%}
|
|
|
|
| 180 |
{%- set m = messages[k] -%}
|
| 181 |
{%- if is_list_of_outputs(m) -%}
|
| 182 |
{%- for entry in m.content -%}
|
|
|
|
| 183 |
{%- set eid = id_of(entry) -%}
|
| 184 |
{%- if not eid -%}
|
| 185 |
{%- set ns_chk.can_sort = false -%}
|
|
@@ -201,6 +203,7 @@ For each function call, output the function name and arguments within the follow
|
|
| 201 |
{%- endif -%}
|
| 202 |
{%- endfor -%}
|
| 203 |
{%- for i in range(ns_a.tool_calls | length) -%}
|
|
|
|
| 204 |
{%- set tc_id = id_of(ns_a.tool_calls[i]) -%}
|
| 205 |
{%- if not tc_id -%}
|
| 206 |
{%- set ns_chk.can_sort = false -%}
|
|
@@ -208,6 +211,7 @@ For each function call, output the function name and arguments within the follow
|
|
| 208 |
{%- for j in range(i + 1, ns_a.tool_calls | length) -%}
|
| 209 |
{%- if id_of(ns_a.tool_calls[j]) == tc_id -%}
|
| 210 |
{%- set ns_chk.can_sort = false -%}
|
|
|
|
| 211 |
{%- endif -%}
|
| 212 |
{%- endfor -%}
|
| 213 |
{%- endfor -%}
|
|
@@ -248,4 +252,4 @@ For each function call, output the function name and arguments within the follow
|
|
| 248 |
{%- endfor -%}
|
| 249 |
{%- if add_generation_prompt -%}
|
| 250 |
<|assistant|>{{- '<think>' -}}
|
| 251 |
-
{%- endif -%}
|
|
|
|
| 62 |
{{- "<reminder>You are unable to process this " ~ media_type ~ " because you don't have multi-modal input ability. Try different methods.</reminder>" }}
|
| 63 |
{%- endif -%}
|
| 64 |
{%- endfor -%}
|
| 65 |
+
{%- elif content is not none -%}
|
| 66 |
{{- content }}
|
| 67 |
{%- endif -%}
|
| 68 |
{%- endmacro -%}
|
|
|
|
| 177 |
{%- set ns_chk.can_sort = false -%}
|
| 178 |
{%- else -%}
|
| 179 |
{%- for k in range(block_start, ns_blk.end + 1) -%}
|
| 180 |
+
{%- if not ns_chk.can_sort -%}{%- break -%}{%- endif -%}
|
| 181 |
{%- set m = messages[k] -%}
|
| 182 |
{%- if is_list_of_outputs(m) -%}
|
| 183 |
{%- for entry in m.content -%}
|
| 184 |
+
{%- if not ns_chk.can_sort -%}{%- break -%}{%- endif -%}
|
| 185 |
{%- set eid = id_of(entry) -%}
|
| 186 |
{%- if not eid -%}
|
| 187 |
{%- set ns_chk.can_sort = false -%}
|
|
|
|
| 203 |
{%- endif -%}
|
| 204 |
{%- endfor -%}
|
| 205 |
{%- for i in range(ns_a.tool_calls | length) -%}
|
| 206 |
+
{%- if not ns_chk.can_sort -%}{%- break -%}{%- endif -%}
|
| 207 |
{%- set tc_id = id_of(ns_a.tool_calls[i]) -%}
|
| 208 |
{%- if not tc_id -%}
|
| 209 |
{%- set ns_chk.can_sort = false -%}
|
|
|
|
| 211 |
{%- for j in range(i + 1, ns_a.tool_calls | length) -%}
|
| 212 |
{%- if id_of(ns_a.tool_calls[j]) == tc_id -%}
|
| 213 |
{%- set ns_chk.can_sort = false -%}
|
| 214 |
+
{%- break -%}
|
| 215 |
{%- endif -%}
|
| 216 |
{%- endfor -%}
|
| 217 |
{%- endfor -%}
|
|
|
|
| 252 |
{%- endfor -%}
|
| 253 |
{%- if add_generation_prompt -%}
|
| 254 |
<|assistant|>{{- '<think>' -}}
|
| 255 |
+
{%- endif -%}
|