246eb97ac466 · 284B
{{- range $i, $_ := .Messages }}
{{- $last := eq (len (slice $.Messages $i)) 1 -}}
<|{{ .Role }}|>
{{ .Content }}{{ if eq .Role "assistant" }}<|end_of_text|>{{ end }}{{ if not $last }}
{{ end }}
{{- if and (ne .Role "assistant") $last }}
<|assistant|>
{{ end }}
{{- end }}