3 an hour ago

vision tools
14b300e2a1ad ยท 1.6kB
{{- if .Messages }}
{{- if or .System .Tools }}
user
{{- if .System }}
{{ .System }}
{{- end }}
{{- if .Tools }}
# Tools
You may call one or more functions to assist with the user query.
Provide function definitions as JSON within the following block:
{{- range .Tools }}
{"type": "function", "function": {{ .Function | json }}}
{{- end }}
For each function call, return a JSON object with the function name and arguments within <tool_call>...</tool_call> tags:
{"name": "<function_name>", "arguments": {<arguments_json>}}
Rules:
- Call a tool only when the user's request genuinely requires external data or an action.
- Prefer one well-formed call over multiple speculative calls.
- Arguments must exactly match the schema; omit optional fields when unknown.
- If no tool fits, answer directly without a tool call.
- Never fabricate tool results.
{{- end }}
{{- end }}
{{- range $i, $_ := .Messages }}
{{- $last := eq (len (slice $.Messages $i)) 1 -}}
{{- if eq .Role "user" }}
user
{{ .Content }}
{{ else if eq .Role "assistant" }}
model
{{ if .Content }}{{ .Content }}
{{- else if .ToolCalls }}
{{- range .ToolCalls }}
{"name": "{{ .Function.Name }}", "arguments": {{ .Function.Arguments | json }}}
{{- end }}
{{- end }}
{{ if not $last }} {{ end }}
{{ else if eq .Role "tool" }}
user
{{ .Content }}
{{ end }}
{{- if and (ne .Role "assistant") $last }}
model
{{ end }}
{{- end }}
{{- else }}
{{- if .System }}
user
{{ .System }}
{{ end }}
{{ if .Prompt }}
user
{{ .Prompt }}
{{ end }}
model
{{ .Response }}{{ if .Response }} {{ end }}
{{- end }}