File size: 1,013 Bytes
8db1e8c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
[gMASK]<sop>{{- /* ---------- tools section ---------- */}}
{{- if .Tools }}
<|system|>
# Available Tools
{{- range .Tools }}
## {{- if .Function }}{{ .Function.Name }}{{- else }}{{ .Name }}{{- end }}

{{ json .Function }}
When calling one of the tools above, pass the arguments in JSON format.
{{- end }}
{{- end }}

{{/* ---------- system messages ---------- */}}
{{- range .Messages }}
  {{- if eq .Role "system" }}
<|system|>
{{ .Content }}
  {{- end }}
{{- end }}

{{/* ---------- user / assistant / observation ---------- */}}
{{- range .Messages }}
  {{- if ne .Role "system" }}
    {{- if eq .Role "user" }}
<|user|>
{{ .Content }}
    {{- else if eq .Role "assistant" }}
      {{- if .ToolCalls }}{{/* assistant function-call */}}
<|assistant|>{{ json .ToolCalls }}
{{ .Content }}
      {{- else }}{{/* normal assistant message */}}
<|assistant|>
{{ .Content }}
      {{- end }}
    {{- else if eq .Role "observation" }}
<|observation|>
{{ .Content }}
    {{- end }}
  {{- end }}
{{- end }}
<|assistant|>