5,058 9 months ago

Tool calling for deepseek-r1, tweaked for the goose agent

tools 70b
b38ece0d806d · 1.6kB
{{- if .Messages }}
{{- if or .System .Tools }}
{{- if .System }}
{{ .System }}
{{- end }}
{{- if .Tools }}
The following tools are available when needed for specific tasks:
{{ .Tools }}
Only use tools when the task specifically requires their functionality.
For general questions or tasks that don't need external data, respond directly.
Pay special attention to tools that can write or edit files.
When using a tool, format as:
<|tool▁calls▁begin|>
<|tool▁call▁begin|>
{"name": "function_name", "parameters": {"param1": "value1"}}
<|tool▁call▁end|>
<|tool▁calls▁end|>
{{- end }}
{{- end }}
{{- range $i, $_ := .Messages }}
{{- $last := eq (len (slice $.Messages $i)) 1 }}
{{- if eq .Role "user" }}<|User|>
{{ .Content }}
{{- if $last }}<|Assistant|>{{ end }}
{{- else if eq .Role "assistant" }}
<|Assistant|>
{{- if .ToolCalls }}
<|tool▁calls▁begin|>
{{- range .ToolCalls }}
<|tool▁call▁begin|>
{"name": "{{ .Function.Name }}", "parameters": {{ .Function.Arguments }}}
<|tool▁call▁end|>
{{- end }}
<|tool▁calls▁end|>
{{- else }}
{{ .Content }}
{{- if not $last }}<|end▁of▁sentence|>{{- end }}
{{- end }}
{{- else if eq .Role "tool" }}
<|tool▁outputs▁begin|>
<|tool▁output▁begin|>
{{ .Content }}
<|tool▁output▁end|>
<|tool▁outputs▁end|>
{{- if and $last (ne .Role "assistant") }}<|Assistant|>{{- end }}
{{- end }}
{{- end }}
{{- else }}
{{- if .System }}
{{ .System }}
{{- end }}
{{- if .Prompt }}
<|User|>
{{ .Prompt }}
{{- end }}
<|Assistant|>
{{ .Response }}
{{- if .Response }}{{ end }}
{{- end }}