danielhanchen commited on
Commit
0e01cb0
·
verified ·
1 Parent(s): c9e4795

Create template

Browse files
Files changed (1) hide show
  1. template +48 -0
template ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 .Content }}{{ .Content }}
36
+ {{- else if .ToolCalls }}<tool_call>
37
+ {{ range .ToolCalls }}{"name": "{{ .Function.Name }}", "arguments": {{ .Function.Arguments }}}
38
+ {{ end }}</tool_call>
39
+ {{- end }}{{ if not $last }}<|im_end|>
40
+ {{ end }}
41
+ {{- else if eq .Role "tool" }}<|im_start|>user
42
+ <tool_response>
43
+ {{ .Content }}
44
+ </tool_response><|im_end|>
45
+ {{ end }}
46
+ {{- if and (ne .Role "assistant") $last }}<|im_start|>assistant
47
+ {{ end }}
48
+ {{- end }}