Update chat template to use XML tool call format.
Browse files- chat_template.jinja +10 -8
chat_template.jinja
CHANGED
|
@@ -8,12 +8,13 @@
|
|
| 8 |
{{- "\n" }}
|
| 9 |
{{- tool | tojson }}
|
| 10 |
{%- endfor %}
|
| 11 |
-
{{- "\n</tools>\n\nFor each function call,
|
| 12 |
{%- else %}
|
| 13 |
{%- if messages[0].role == 'system' %}
|
| 14 |
{{- '<|im_start|>system\n' + messages[0].content + '<|im_end|>\n' }}
|
| 15 |
{%- endif %}
|
| 16 |
{%- endif %}
|
|
|
|
| 17 |
{%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}
|
| 18 |
{%- for message in messages[::-1] %}
|
| 19 |
{%- set index = (messages|length - 1) - loop.index0 %}
|
|
@@ -57,15 +58,16 @@
|
|
| 57 |
{%- if tool_call.function %}
|
| 58 |
{%- set tool_call = tool_call.function %}
|
| 59 |
{%- endif %}
|
| 60 |
-
{{- '<tool_call
|
| 61 |
-
{{- tool_call.name }}
|
| 62 |
-
{{- '", "arguments": ' }}
|
| 63 |
{%- if tool_call.arguments is string %}
|
| 64 |
-
{
|
| 65 |
{%- else %}
|
| 66 |
-
{
|
| 67 |
{%- endif %}
|
| 68 |
-
{
|
|
|
|
|
|
|
|
|
|
| 69 |
{%- endfor %}
|
| 70 |
{%- endif %}
|
| 71 |
{{- '<|im_end|>\n' }}
|
|
@@ -86,4 +88,4 @@
|
|
| 86 |
{%- if enable_thinking is defined and enable_thinking is false %}
|
| 87 |
{{- '<think>\n\n</think>\n\n' }}
|
| 88 |
{%- endif %}
|
| 89 |
-
{%- endif %}
|
|
|
|
| 8 |
{{- "\n" }}
|
| 9 |
{{- tool | tojson }}
|
| 10 |
{%- endfor %}
|
| 11 |
+
{{- "\n</tools>\n\nFor each function call, use this XML format:\n\n<function=function_name>\n <parameter=param1>value1</parameter>\n <parameter=param2>value2</parameter>\n</function>\n" }}
|
| 12 |
{%- else %}
|
| 13 |
{%- if messages[0].role == 'system' %}
|
| 14 |
{{- '<|im_start|>system\n' + messages[0].content + '<|im_end|>\n' }}
|
| 15 |
{%- endif %}
|
| 16 |
{%- endif %}
|
| 17 |
+
|
| 18 |
{%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}
|
| 19 |
{%- for message in messages[::-1] %}
|
| 20 |
{%- set index = (messages|length - 1) - loop.index0 %}
|
|
|
|
| 58 |
{%- if tool_call.function %}
|
| 59 |
{%- set tool_call = tool_call.function %}
|
| 60 |
{%- endif %}
|
| 61 |
+
{{- '<function=' + tool_call.name + '>\n' }}
|
|
|
|
|
|
|
| 62 |
{%- if tool_call.arguments is string %}
|
| 63 |
+
{%- set args = tool_call.arguments | fromjson %}
|
| 64 |
{%- else %}
|
| 65 |
+
{%- set args = tool_call.arguments %}
|
| 66 |
{%- endif %}
|
| 67 |
+
{%- for param_name, param_value in args.items() %}
|
| 68 |
+
{{- ' <parameter=' + param_name + '>' + param_value + '</parameter>\n' }}
|
| 69 |
+
{%- endfor %}
|
| 70 |
+
{{- '</function>' }}
|
| 71 |
{%- endfor %}
|
| 72 |
{%- endif %}
|
| 73 |
{{- '<|im_end|>\n' }}
|
|
|
|
| 88 |
{%- if enable_thinking is defined and enable_thinking is false %}
|
| 89 |
{{- '<think>\n\n</think>\n\n' }}
|
| 90 |
{%- endif %}
|
| 91 |
+
{%- endif %}
|