228 4 months ago

vision tools 1b 4b 12b 27b
42ef6768d3a8 · 1.5kB
{{- if .System }}<start_of_turn>system
{{ .System }}
{{- end }}<end_of_turn>
{{- range $i, $_ := .Messages }}
{{- $last := eq (len (slice $.Messages $i)) 1 }}
{{- if eq .Role "user" }}<start_of_turn>user
{{- if and $.Tools $last }}
{{- /* Tool Calling instruction is from this gemma3 official document */ -}}
{{- /* https://ai.google.dev/gemma/docs/capabilities/function-calling?hl=ja#function-calling-setup */ -}}
You have access to functions. If you decide to invoke any of the function(s),
you MUST put it in the format of
{"name": function name, "parameters": dictionary of argument name and its value}
You SHOULD NOT include any other text in the response if you call a function
{{- /* Tool List */ -}}
{{ range $.Tools }}
{{- . }}
{{ end }}
{{- /* Output format */ -}}
For each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:
<tool_call>
{"name": <function-name>, "arguments": <args-json-object>}
</tool_call>
{{- end }}
{{ .Content }}<end_of_turn>
{{- else if eq .Role "assistant" }}<start_of_turn>assistant
{{- if .ToolCalls }}<tool_call>
{{- range .ToolCalls }}{"name": "{{ .Function.Name }}", "parameters": {{ .Function.Arguments
}}}
{{ end }}</tool_call>
{{- else }}<start_on_turn>user
{{ .Content }}{{ if not $last }}<end_of_turn>{{ end }}
{{- end }}
{{- else if eq .Role "tool" }}<start_of_turn>user
{{- /* Tool response if have */ -}}
<tool_response>
{{ .Content }}
</tool_response><end_of_turn>
{{- end }}
{{ if $last }}<start_of_turn>assistant
{{ end }}
{{- end }}