Text Generation
Transformers
GGUF
nvidia
unsloth
imatrix
conversational
danielhanchen's picture
Update template
9ad8b36 verified
Raw
History Blame Contribute Delete
2.64 kB
{{ if .Tools }}<|im_start|>system
# Tools
You have access to the following functions:
<tools>{{ range .Tools }}
<function>
<name>{{ .Function.Name }}</name>{{ if .Function.Description }}
<description>{{ .Function.Description }}</description>{{ end }}
<parameters>{{ range $pname, $p := .Function.Parameters.Properties }}
<parameter>
<name>{{ $pname }}</name>{{ if $p.Type }}
<type>{{ $p.Type }}</type>{{ end }}{{ if $p.Description }}
<description>{{ $p.Description }}</description>{{ end }}{{ if $p.Enum }}
<enum>{{ json $p.Enum }}</enum>{{ end }}
</parameter>{{ end }}{{ if .Function.Parameters.Required }}
<required>{{ json .Function.Parameters.Required }}</required>{{ end }}
</parameters>
</function>
{{ end }}</tools>
If you choose to call a function ONLY reply in the following format with NO suffix:
<tool_call>
<function=example_function_name>
<parameter=example_parameter_1>
value_1
</parameter>
<parameter=example_parameter_2>
This is the value for the second parameter
that can span
multiple lines
</parameter>
</function>
</tool_call>
<IMPORTANT>
Reminder:
- Function calls MUST follow the specified format: an inner <function=...></function> block must be nested within <tool_call></tool_call> XML tags
- Required parameters MUST be specified
- You may provide optional reasoning for your function call in natural language BEFORE the function call, but NOT after
- If there is no function call available, answer the question like normal with your current knowledge and do not tell the user about function calls
</IMPORTANT>{{ if .System }}{{ .System }}{{ end }}<|im_end|>
{{ else }}<|im_start|>system
{{ if .System }}{{ .System }}{{ end }}<|im_end|>
{{ end }}{{ range $i, $_ := .Messages }}{{ $last := eq (len (slice $.Messages $i)) 1 }}{{ if eq .Role "user" }}<|im_start|>user
{{ if .Images }}{{ range .Images }}[{'type': 'image'}, {'type': 'text', 'text': '{{ end }}{{ end }}{{ .Content }}<|im_end|>
{{ end }}{{ if eq .Role "assistant" }}{{ if .ToolCalls }}<|im_start|>assistant
<think></think>
{{ range $i, $tc := .ToolCalls }}{{ if $i }}
{{ end }}<tool_call>
<function={{ $tc.Function.Name }}>
{{ range $k, $v := $tc.Function.Arguments }}<parameter={{ $k }}>
{{ if eq (printf "%T" $v) "string" }}{{ $v }}{{ else }}{{ json $v }}{{ end }}
</parameter>
{{ end }}</function>
</tool_call>{{ end }}
<|im_end|>
{{ else }}<|im_start|>assistant
<think></think>{{ if .Content }}{{ .Content }}{{ end }}<|im_end|>
{{ end }}{{ end }}{{ if eq .Role "tool" }}<|im_start|>user
<tool_response>
{{ .Content }}
</tool_response>
<|im_end|>
{{ end }}{{ if and $last (ne .Role "assistant") }}<|im_start|>assistant
<think>
{{ end }}{{ end }}