danielhanchen commited on
Commit
a9b37aa
·
verified ·
1 Parent(s): c82fc36

Create template

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