<s>{{ if .Tools }}{{ if and $.Messages (eq (index $.Messages 0).Role "system") }}<|im_start|>system
{{ (index $.Messages 0).Content }}
# Tools
You are provided with function signatures within <tools></tools> XML tags:
<tools>{{ range .Tools }}
{{ . }}{{ end }}
</tools>
Tool usage guidelines:
- You may call zero or more functions. If no function calls are needed, just answer normally and do not include any <function ... </function>.
- When calling a function, return an XML object within <function ... </function> using:
<function name="function-name"><param name="param-name">param-value</param></function>
- param-value may be multi-line. If it contains <, & or newline characters, wrap it in a CDATA block: <param name="param-name"><![CDATA[...multi-line value...]]></param><|im_end|>
{{ else }}<|im_start|>system
# Tools
You are provided with function signatures within <tools></tools> XML tags:
<tools>{{ range .Tools }}
{{ . }}{{ end }}
</tools>
Tool usage guidelines:
- You may call zero or more functions. If no function calls are needed, just answer normally and do not include any <function ... </function>.
- When calling a function, return an XML object within <function ... </function> using:
<function name="function-name"><param name="param-name">param-value</param></function>
- param-value may be multi-line. If it contains <, & or newline characters, wrap it in a CDATA block: <param name="param-name"><![CDATA[...multi-line value...]]></param><|im_end|>
{{ end }}{{ else }}{{ if and $.Messages (eq (index $.Messages 0).Role "system") }}<|im_start|>system
{{ (index $.Messages 0).Content }}<|im_end|>
{{ end }}{{ end }}{{ range $i, $m := .Messages }}{{ if or (ne .Role "system") (ne $i 0) }}{{ if eq .Role "tool" }}<|im_start|>user
<tool_response>
{{ .Content }}
</tool_response><|im_end|>
{{ else }}<|im_start|>{{ .Role }}
{{ if eq .Role "assistant" }}{{ if .Thinking }}<think>
{{ .Thinking }}
</think>
{{ else }}<think>
</think>
{{ end }}{{ end }}{{ $content := .Content }}{{ .Content }}{{ if .ToolCalls }}{{ range $j, $tc := .ToolCalls }}{{ if or (and (eq $j 0) (ne $content "")) (ne $j 0) }}
{{ end }}<function name="{{ $tc.Function.Name }}">{{ range $k, $v := $tc.Function.Arguments }}<param name="{{ $k }}">{{ $v }}</param>{{ end }}</function>{{ end }}{{ end }}<|im_end|>
{{ end }}{{ end }}{{ end }}<|im_start|>assistant
{{ if .IsThinkSet }}{{ if .Think }}<think>
{{ else }}<think>
</think>
{{ end }}{{ end }}