KartoffelToby commited on
Commit
12dc0a5
·
verified ·
1 Parent(s): 4758edd

Update template

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