171 7 months ago

Meta Code World Model experimental python coding model

thinking
1859223fbcdd · 803B
{{- $lastUserIdx := -1 -}}
{{- range $idx, $msg := .Messages -}}
{{- if eq $msg.Role "user" }}{{ $lastUserIdx = $idx }}{{ end -}}
{{- end -}}
{{- if .System }}<|start_header_id|>system<|end_header_id|>
{{ .System }}<|eot_id|>
{{- end }}
{{- range $i, $_ := .Messages }}
{{- $last := eq (len (slice $.Messages $i)) 1 -}}
{{- if eq .Role "user" }}<|start_header_id|>user<|end_header_id|>
{{ .Content }}<|eot_id|>
{{- else if eq .Role "assistant" }}<|start_header_id|>assistant<|end_header_id|>
{{ if and $.IsThinkSet .Thinking -}}
<think>
{{ .Thinking }}</think>
{{- end -}}
{{ .Content }}{{ if not $last }}<|eot_id|>{{ end }}
{{- end }}
{{- if and (ne .Role "assistant") $last }}<|start_header_id|>assistant<|end_header_id|>
{{ if and $.IsThinkSet $.Think }}<think>
{{ end -}}
{{ end }}
{{- end }}