danielhanchen commited on
Commit
196efa7
·
verified ·
1 Parent(s): e66f34d

Create template

Browse files
Files changed (1) hide show
  1. template +50 -0
template ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {{- $lastUserIdx := -1 -}}
2
+ {{- range $idx, $msg := .Messages -}}
3
+ {{- if eq $msg.Role "user" }}{{ $lastUserIdx = $idx }}{{ end -}}
4
+ {{- end }}
5
+ {{- if or .System .Tools }}<|im_start|>system
6
+ {{ if .System }}
7
+ {{ .System }}
8
+ {{- end }}
9
+ {{- if .Tools }}
10
+
11
+ # Tools
12
+
13
+ You may call one or more functions to assist with the user query.
14
+
15
+ You are provided with function signatures within <tools></tools> XML tags:
16
+ <tools>
17
+ {{- range .Tools }}
18
+ {"type": "function", "function": {{ .Function }}}
19
+ {{- end }}
20
+ </tools>
21
+
22
+ For each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:
23
+ <tool_call>
24
+ {"name": <function-name>, "arguments": <args-json-object>}
25
+ </tool_call>
26
+ {{- end -}}
27
+ <|im_end|>
28
+ {{ end }}
29
+ {{- range $i, $_ := .Messages }}
30
+ {{- $last := eq (len (slice $.Messages $i)) 1 -}}
31
+ {{- if eq .Role "user" }}<|im_start|>user
32
+ {{ .Content }}<|im_end|>
33
+ {{ else if eq .Role "assistant" }}<|im_start|>assistant
34
+ {{ if (and $.IsThinkSet (and .Thinking (or $last (gt $i $lastUserIdx)))) -}}
35
+ <think>{{ .Thinking }}</think>
36
+ {{ end -}}
37
+ {{ if .Content }}{{ .Content }}
38
+ {{- else if .ToolCalls }}<tool_call>
39
+ {{ range .ToolCalls }}{"name": "{{ .Function.Name }}", "arguments": {{ .Function.Arguments }}}
40
+ {{ end }}</tool_call>
41
+ {{- end }}{{ if not $last }}<|im_end|>
42
+ {{ end }}
43
+ {{- else if eq .Role "tool" }}<|im_start|>user
44
+ <tool_response>
45
+ {{ .Content }}
46
+ </tool_response><|im_end|>
47
+ {{ end }}
48
+ {{- if and (ne .Role "assistant") $last }}<|im_start|>assistant
49
+ {{ end }}
50
+ {{- end }}