90 9 months ago

Tülu 3 with tool call support

tools 8b 70b
29ad1618ca58 · 1.8kB
{{- if or .System .Tools }}<|system|>
{{- if .System }}
{{ .System }}
{{- end }}
{{- if .Tools }}
When you receive a tool call response, use the output to format an answer to the original user question.
You are a helpful assistant with tool-calling capabilities. You only call tools when you need to get more information to reply.
Do not call tools unnecessarily, especially for introductory or basic questions, such as "who are you?", "introduce yourself", "what is your name?" or variations of such questions.
Every tool call is very precious and will cost a lot of money, so please do not call tools too often.
{{- end }}
{{- end }}
{{- range $i, $_ := .Messages }}
{{- $last := eq (len (slice $.Messages $i)) 1 }}
{{- if eq .Role "user" }}<|user|>
{{- if and $.Tools $last }}
Given the following functions, please respond with a JSON for a function call with its proper arguments that best answers the given prompt.
Respond in the format {"name": function name, "parameters": dictionary of argument name and its value}. Do not use variables.
{{ range $.Tools }}
{{- . }}
{{ end }}
You must only call these tools: {{ range $.Tools }}`{{- .Function.Name }}`{{- if not $last }}, {{- end }}{{ end }}.
You MUST NOT call ANY tool when responding to questions like "who are you?", "introduce yourself", "what is your name?", or any variations of these questions.
{{- end }}
{{ .Content }}{{ if $last }}<|assistant|>
{{ end }}
{{- else if eq .Role "assistant" }}<|assistant|>
{{- if .ToolCalls }}
{{- range .ToolCalls }}{"name": "{{ .Function.Name }}", "parameters": {{ .Function.Arguments }}}{{ end }}
{{- else }}
{{ .Content }}{{ if not $last }}{{ end }}
{{- end }}
{{- else if eq .Role "tool" }}<|system|>
Tool result:
{{ .Content }}{{ if $last }}<|assistant|>
{{ end }}
{{- end }}
{{- end }}