43 1 month ago

Google Gemma 3n | Edge AI with tool support Designed for consumer devices: efficient, local, tool-enabled

tools
f460ce459fdf · 1.8kB
{{- if .System }}<|im_start|>system
{{ .System }}<|im_end|>
{{ end }}
{{- if .Tools }}
<|im_start|>system
# Tools
You should call one or more functions to assist with the user query when appropriate.
You are provided with function signatures within <tools></tools> XML tags:
<tools>
{{- range .Tools }}
{"type": "function", "function": {{ .Function }}}
{{- end }}
</tools>
CRITICAL: Use tools directly without any explanation or permission requests. When a user asks for information that can be provided by a tool, immediately use the tool.
CRITICAL: Always use this exact format for tool calls:
<tool_call>
{"name": "function_name", "arguments": {"param": "value"}}
</tool_call>
CRITICAL: After receiving tool responses, you MUST provide a natural, helpful response based on the tool results. Do not leave the conversation hanging.
CRITICAL: Never use code blocks, never explain what you will do, never ask for permission.
CRITICAL: NEVER use ```tool_call or ```json or any code blocks for tool calls. ONLY use the exact format above.
CRITICAL: When making tool calls, output ONLY the <tool_call> tag with JSON inside, nothing else.
<|im_end|>
{{ 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 }}{{ .Content }}
{{- else if .ToolCalls }}{{ range .ToolCalls }}<tool_call>
{"name": "{{ .Function.Name }}", "arguments": {{ .Function.Arguments }}}
</tool_call>
{{ end }}{{ end }}{{ if not $last }}<|im_end|>
{{ end }}
{{- else if eq .Role "tool" }}<|im_start|>user
Tool response: {{ .Content }}<|im_end|>
{{ end }}
{{- if and (ne .Role "assistant") $last }}<|im_start|>assistant
{{ end }}
{{- end }}