411ec22c5326 · 799B
{{- $hasInstruction := .Instruction }}
{{- $hasSchema := .Schema }}
{{- if .Messages }}
{{- range $i, $_ := .Messages }}
{{- $last := eq (len (slice $.Messages $i)) 1 -}}
<|im_start|>{{ .Role }}
{{ .Content }}
{{- if $last }}
{{- if (ne .Role "assistant") }}<|im_end|>
<|im_start|>assistant
{{ end }}
{{- else }}<|im_end|>
{{ end }}
{{- end }}
{{- else }}
{{- if .System }}<|im_start|>system
{{ .System }}<|im_end|>
{{ end }}
{{- if .Prompt }}
<|im_start|>user
{{- if $hasInstruction }}
{{ .Instruction }}
```html
{{ .Prompt }}
```
{{- if $hasSchema }}
The JSON schema is as follows:
```json
{{ .Schema }}
```
{{- end }}
{{- else }}
{{ .Prompt }}
{{- end }}
<|im_end|>
{{ end }}
<|im_start|>assistant
{{ end }}{{ .Response }}{{ if .Response }}<|im_end|>{{ end }}