43 1 month ago

vision tools thinking
764c140f791c · 1.4kB
{{- range $index, $_ := .Messages }}
{{- $last := eq (len (slice $.Messages $index)) 1}}
{{- if eq .Role "system" }}
[SYSTEM_PROMPT]
{{- if and $.IsThinkSet $.Think }}
First draft your thinking process (inner monologue) until you arrive at a response. Write both your thoughts and the response in the same language as the input.
Your thinking process must follow the template below:
[THINK]Your thoughts or/and draft, like working through an exercise on scratch paper. Be as casual and as long as you want until you are confident to generate the response. Use the same language as the input.[/THINK]
Here, provide a self-contained response.
{{ .Content }}
{{- else }}
{{ .Content }}
{{- end }}
[/SYSTEM_PROMPT]
{{- else if eq .Role "user" }}
{{- if and (le (len (slice $.Messages $index)) 2) $.Tools }}[AVAILABLE_TOOLS]{{ $.Tools }}[/AVAILABLE_TOOLS]{{- end }}
[INST]{{ .Content }}[/INST]
{{- else if eq .Role "assistant" }}
{{- if and $.IsThinkSet (and $last .Thinking) -}}[THINK]{{ .Thinking }}[/THINK]{{- end }}
{{- if .Content }}{{ .Content }}{{- if not (eq (len (slice $.Messages $index)) 1) }}</s>{{- end }}
{{- else if .ToolCalls }}[TOOL_CALLS][
{{- range .ToolCalls }}{"name": "{{ .Function.Name }}", "arguments": {{ .Function.Arguments }}}{{- end }}]</s>
{{- end }}
{{- else if eq .Role "tool" }}
[TOOL_RESULTS]{"content": {{ .Content }}}[/TOOL_RESULTS]
{{- end }}
{{- end }}