yesterday

tools thinking
73cbe832b693 · 1.1kB
{{- if .System }}<|im_start|>system
{{ .System }}<|im_end|>
{{- else }}<|im_start|>system
You are RWKV, a helpful assistant.<|im_end|>
{{- end }}
{{- if .Tools }}<|im_start|>system
You have access to the following tools:
<tools>
{{ json .Tools }}
</tools>
To use a tool, output <tool_call>{"name": "function", "arguments": {}}</tool_call>
<|im_end|>
{{- end }}
{{- range $i, $_ := .Messages }}
{{- $last := eq (len (slice $.Messages $i)) 1}}
{{- if eq .Role "user" }}
{{- if eq $i 0}}<|im_start|>user
{{ .Content }}<|im_end|>
{{- else }}
<|im_start|>user
{{ .Content }}<|im_end|>
{{- end }}
{{- else if eq .Role "assistant" }}
<|im_start|>assistant
{{- if and $last .Thinking }}<think>
{{ .Thinking }}
</think>
{{- end }}{{ if .Content }}{{ .Content }}{{ end }}{{- if .ToolCalls }}
<tool_call>
{{- range .ToolCalls }}
{{ json .Function }}
{{- end }}
</tool_call>
{{- end }}<|im_end|>
{{- else if eq .Role "tool" }}
<|im_start|>tool
<tool_response>
{{ .Content }}
</tool_response><|im_end|>
{{- end }}
{{- if and $last (ne .Role "assistant") }}
<|im_start|>assistant
{{- end }}{{- end }}