225 1 month ago

Various Quants of Magidonia.

vision tools thinking 24b
74f6f0bd2474 · 2.0kB
{{- $lastUserIdx := -1 }}
{{- range $i, $msg := .Messages }}
{{- if eq $msg.Role "user" }}
{{- $lastUserIdx = $i }}
{{- end }}
{{- end }}
{{- range $index, $_ := .Messages }}
{{- $last := eq (len (slice $.Messages $index)) 1}}
{{- if and $.IsThinkSet (and $last .Thinking) -}}
<think>{{ .Thinking }}</think>
{{- end }}
{{- end }}
{{- if gt $lastUserIdx 0 }}
{{- range $i, $msg := slice $.Messages 0 $lastUserIdx }}
{{- if eq .Role "user" -}}
[INST]{{ .Content }}[/INST]
{{- end }}
{{- if eq .Role "assistant" }}
{{- if .Thinking }}<think>{{ .Thinking }}</think>
{{- end -}}
{{- if .Content }}{{ .Content }}</s>
{{- end -}}
{{- if .ToolCalls -}}
<tool_call>
{{ range .ToolCalls }}{"name": "{{ .Function.Name }}", "arguments": {{ .Function.Arguments }}}
{{- end -}}
</tool_call>
{{- end -}}
{{- end }}
{{- if eq .Role "tool" -}}
<tool_response>{{ .Content }}</tool_response>
{{- end }}
{{- end }}
{{- end }}
{{ if .Tools -}}
You may call one or more functions to assist with the user query.
You are provided with function signatures within <tools></tools> XML tags:
<tools>
{{- range .Tools }}
{"type": "function", "function": {{ .Function }}}
{{- end }}
</tools>
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 }}
{{ if .System -}}
[SYSTEM_PROMPT]{{ .System }}[/SYSTEM_PROMPT]
{{- end }}
{{ if ge $lastUserIdx 0 }}
{{- range $i, $msg := slice $.Messages $lastUserIdx }}
{{- if eq .Role "user" -}}
[INST]{{ .Content }}[/INST]
{{- end }}
{{- if eq .Role "assistant" }}
{{- if .Thinking }}<think>{{ .Thinking }}</think>
{{- end -}}
{{- if .Content }}{{ .Content }}</s>
{{- end -}}
{{- if .ToolCalls -}}
<tool_call>
{{ range .ToolCalls }}{"name": "{{ .Function.Name }}", "arguments": {{ .Function.Arguments }}}
{{- end -}}
</tool_call>
{{- end -}}
{{- end }}
{{- if eq .Role "tool" -}}
<tool_response>{{ .Content }}</tool_response>
{{- end }}
{{- end }}
{{- end }}<think>