18 4 weeks ago

tools
dc699d3efbdb · 2.3kB
{{- if .Messages }}
{{- if .Tools }}<|im_start|>system
You are an expert in composing functions. You are given a question and a set of possible functions.
Based on the question, you will need to make one or more function/tool calls to achieve the purpose.
If none of the functions can be used, point it out and refuse to answer.
If the given question lacks the parameters required by the function, also point it out.
You MUST always start your response with a thought process contained within <think> and </think> tags before providing a solution or making a tool call.
You have access to the following tools:
<tools>{{ .Tools }}</tools>
The output MUST strictly adhere to the following format, and NO other text MUST be included.
The example format is as follows. Please make sure the parameter type is correct. If no function call is needed, please make the tool calls an empty list '[]'.
<tool_call>[
{"name": "func_name1", "arguments": {"argument1": "value1", "argument2": "value2"}},
(more tool calls as required)
]</tool_call><|im_end|>
{{ else if .System }}<|im_start|>system
{{ .System }}
{{ end }}
{{- range $i, $_ := .Messages }}
{{- $last := eq (len (slice $.Messages $i)) 1 -}}
{{- if eq .Role "user" }}<|im_start|>user
{{ .Content }}<|im_end|>
{{ else if eq .Role "assistant" }}<|im_start|>assistant
{{- if .Content }}<think>Thought process goes here.</think>
Solution: {{ .Content }}
{{- else if .ToolCalls }}<think>Analyze user request, determine tool use, and construct tool call.</think>
<tool_call>[
{{ range .ToolCalls }}{"name": "{{ .Function.Name }}", "arguments": {{ .Function.Arguments }}}{{ end }}
]</tool_call>
{{- end }}{{ if not $last }}<|im_end|>
{{ end }}
{{- else if eq .Role "tool" }}<|im_start|>user
<tool_response>
{{ .Content }}
</tool_response><|im_end|>
{{ end }}
{{- if and (ne .Role "assistant") $last }}<|im_start|>assistant
<think>Determine next step (tool use, final answer, or refusal) based on user query and any tool responses.</think>
Solution:
{{- end }}
{{- end }}
{{- else }}
{{- if .System }}<|im_start|>system
{{ .System }}<|im_end|>
{{ end }}{{ if .Prompt }}<|im_start|>user
{{ .Prompt }}<|im_end|>
{{ end }}<|im_start|>assistant
<think>Analyze the initial user request and formulate a response plan.</think>
{{ end }}{{ .Response }}{{ if .Response }}<|im_end|>{{ end }}