<SPECIAL_10>System
{{- if .System }}
{{ .System }}
{{- end }}
{{- if .Tools }}
You can use the following tools to assist the user if required:
<AVAILABLE_TOOLS>[
{{- range $i, $tool := .Tools }}
{{- if gt $i 0 }}, {{ end -}}
{{- if $tool.Function }}{{ $tool.Function }}{{ else }}{{ $tool }}{{ end -}}
{{- end }}
]</AVAILABLE_TOOLS>
If you decide to call any tool(s), use the following format:
<TOOLCALL>[{"name":"tool_name1","arguments":{"arg":"value"}},{"name":"tool_name2","arguments":{"arg":"value"}}]</TOOLCALL>
The user will execute tool-calls and return responses from tool(s) in this format:
<TOOL_RESPONSE>[{"tool_response1"},{"tool_response2"}]</TOOL_RESPONSE>
Based on the tool responses, you can call additional tools if needed, correct tool calls if any errors are found, or just respond to the user.
{{- end }}
{{- "\n" -}}
{{- range .Messages }}
{{- if eq .Role "user" }}
<SPECIAL_11>User
{{ .Content }}
{{- else if eq .Role "tool" }}
<SPECIAL_11>User
<TOOL_RESPONSE>[{{ .Content }}]</TOOL_RESPONSE>
{{- else if eq .Role "assistant" }}
<SPECIAL_11>Assistant
{{- if .Thinking }}<think>{{ .Thinking }}</think>
{{- end }}
{{- if .Content }}{{ .Content }}{{ end -}}
{{- if .ToolCalls }}
{{- if .Content }}
{{- end -}}
<TOOLCALL>[
{{- range $i, $call := .ToolCalls -}}
{{- if gt $i 0 }}, {{ end -}}
{{- $fn := $call.Function -}}
{"name":"{{ $fn.Name }}","arguments":{{ $fn.Arguments }}}
{{- end -}}
]</TOOLCALL>
{{- end }}
<SPECIAL_12>
{{- end }}
{{- end }}
{{- if .Response }}
<SPECIAL_11>Assistant
{{- if .Think }}<think>
{{- else }}<think></think>{{- end }}
{{ .Response }}
{{- else }}
<SPECIAL_11>Assistant
{{- if .Think }}<think>
{{- else }}<think></think>{{- end }}
{{- end -}}