Motif-2-12.7B-Instruct / chat_template.jinja
SungminLee's picture
upload_weights (#1)
ed49ed9 verified
<|beginoftext|>{%- for message in messages -%}
<|startofturn|>{%- if message.role == "system" -%}
<|system|>
{{ message.content }}
{% if tools is defined and tools %}
# Tools
You may call one or more functions to assist with the user query.
You are provided with function signatures within <tools></tools> XML tags:
<tools>
{%- for tool in tools %}
{{ tool | tojson }}
{%- if not loop.last %}
{%- endif %}
{%- endfor %}
</tools>
Use this exact JSON schema for each tool call:
{"properties":{"name":{"title":"Name","type":"string"},"arguments":{"title":"Arguments","type":"object"}},"required":["name","arguments"],"title":"FunctionCall","type":"object"}
For each function call return a json object with function name and arguments within <tool_call></tool_call> XML tags as follows:
<tool_call>
{"name": <function-name>, "arguments": <args-dict>}
</tool_call>
{% endif %}
{{- '<|endofturn|>' }}{%- elif message.role == "user" -%}
<|user|>
{{ message.content }}
<|endofturn|>{%- elif message.role == "assistant" -%}
<|assistant|>
{%- set raw_calls = (message.tool_calls if (message.tool_calls is defined and message.tool_calls) else message.tool_call) %}
{%- if raw_calls %}
{%- set tool_calls = (raw_calls if (raw_calls is iterable and (raw_calls is not mapping) and (raw_calls is not string)) else [raw_calls]) %}
{%- for tc in tool_calls %}
{%- set call = (tc.function if tc.function is defined else tc) %}
<tool_call>
{"name": "{{ call.name }}", "arguments": {{ call.arguments if call.arguments is string else (call.arguments|default({})|tojson) }}}
</tool_call>
{%- endfor %}
{%- endif %}
{%- if message.thinking is defined and message.thinking %}
{{ '<think>' }}
{{ message.thinking }}
{{ '</think>' }}
{% endif %}
{{ message.content }}
<|endofturn|>{%- elif message.role == "tool" -%}
<|tool|>
<tool_response>
{{ message.content }}
</tool_response><|endofturn|>
{%- endif -%}
{%- endfor -%}
{%- if add_generation_prompt and enable_thinking %}
{{- '<|assistant|><think>\n' }}
{%- elif add_generation_prompt %}
{{- '<|assistant|>\n' }}
{%- else %}
<|endoftext|>
{%- endif %}