434 1 month ago

A Gemma3 model with integrated tool support, fully compatible with the latest Ollama release.

vision tools 1b 4b 12b 27b
7c410b21783c · 2.4kB
{{- /* System message at the beginning, if there is .System or .Tools */ -}}
{{- if or .System .Tools }}
<start_of_turn>user
{{- if .System }}
{{ .System }}
{{- end }}
{{- if .Tools }}
You are a helpful assistant with the ability to call tools. However, you should use tools only when it is truly necessary to answer the user's question.
**When to use tools:**
- The user requests current information (for example, weather, news, exchange rates).
- The user asks to perform calculations or data processing that are beyond your built-in capabilities.
- The user requests information that you are unsure about or do not have.
**When NOT to use tools:**
- Simple greetings or general questions that can be answered based on your knowledge or common sense.
- Questions that do not require external data or complex calculations.
**Examples:**
- Q: "Hi, how are you?"
A: "Hi! I'm fine, thank you. How can I help?" (no tool).
- Q: "What is artificial intelligence?"
A: definition based on knowledge (no tool).
- Q: "What is the weather in Moscow?"
→ call a weather tool.
⚠️ **When you call a tool, your response MUST start _exactly_ with:**
<tool_call>
{"name": "...", "parameters": { ... }}
</tool_call>
_No markdown ``` fences, no extra text and **no line break before `<tool_call>`**._
**Available tools:**
<tools>
{{- range .Tools }}
{"type": "function", "function": {{ .Function }}}
{{- end }}
</tools>
**Tool call format (example):**
<tool_call>
{"name": "tool_name", "parameters": {"param1": "value1", "param2": "value2"}}
</tool_call>
{{- end }}
<end_of_turn>
{{- end }}
{{- /* Processing messages */ -}}
{{- range $i, $_ := .Messages }}
{{- $last := eq (len (slice $.Messages $i)) 1 }}
{{- /* User messages */ -}}
{{- if eq .Role "user" }}
<start_of_turn>user
{{ .Content }}<end_of_turn>
{{ if $last }}<start_of_turn>model{{ end }}
{{- /* Assistant messages */ -}}
{{- else if eq .Role "assistant" }}<start_of_turn>model{{- if .ToolCalls }}<tool_call>{{- range .ToolCalls }}{"name":"{{ .Function.Name }}","parameters":{{ .Function.Arguments }}}{{- end }}</tool_call>{{- else }}{{ .Content }}{{- end }}{{- if not $last }}<end_of_turn>{{ end }}
{{- /* Tool results */ -}}
{{- else if eq .Role "tool" }}
<start_of_turn>user
<tool_response>
{{ .Content }}
</tool_response><end_of_turn>
{{ if $last }}<start_of_turn>model{{ end }}
{{- end }}
{{- end }}