3,223 6 days ago

Apertus is a 70B and 8B parameter language model designed to push the boundaries of fully-open multilingual and transparent models.

tools thinking
52885c47c324 · 2.2kB
<s>
{{- $hasSystem := false -}}
{{- $systemContent := "" -}}
{{- range $i, $m := .Messages -}}
{{- if and (eq $i 0) (eq $m.Role "system") -}}
{{- $hasSystem = true -}}
{{- $systemContent = $m.Content -}}
{{- end -}}
{{- end -}}
{{- if $hasSystem -}}
<|system_start|>{{ $systemContent }}<|system_end|>
{{- else -}}
<|system_start|>You are Apertus, a helpful assistant created by the SwissAI initiative.
Knowledge cutoff: 2024-04
Current date: {{ currentDate }}<|system_end|>
{{- end -}}
{{- $thinkOn := and .IsThinkSet .Think -}}
<|developer_start|>Deliberation: {{ if $thinkOn }}enabled{{ else }}disabled{{ end }}
Tool Capabilities:
{{- if .Tools -}}
{{- range .Tools }}
{{ . | json }}
{{- end }}
{{- else }} disabled
{{- end -}}
<|developer_end|>
{{- $inAssistant := false -}}
{{- $inTool := false -}}
{{- range $i, $m := .Messages -}}
{{- if eq $m.Role "system" -}}
{{- /* already emitted above when i==0 */ -}}
{{- else if eq $m.Role "user" -}}
{{- if $inTool -}}]{{- $inTool = false -}}{{- end -}}
{{- if $inAssistant -}}<|assistant_end|>{{- $inAssistant = false -}}{{- end -}}
<|user_start|>{{ $m.Content }}<|user_end|>
{{- else if eq $m.Role "assistant" -}}
{{- if $inTool -}}]{{- $inTool = false -}}{{- end -}}
{{- if not $inAssistant -}}<|assistant_start|>{{- $inAssistant = true -}}{{- end -}}
{{- $thinkingOpen := false -}}
{{- if $m.Thinking -}}<|inner_prefix|>{{ $m.Thinking }}{{- $thinkingOpen = true -}}{{- end -}}
{{- if $m.Content -}}{{- if $thinkingOpen -}}<|inner_suffix|>{{- $thinkingOpen = false -}}{{- end -}}{{ $m.Content }}{{- end -}}
{{- if $m.ToolCalls -}}
{{- if and $thinkingOpen (eq (len $m.ToolCalls) 1) -}}
{{- $onlyCall := index $m.ToolCalls 0 -}}
{{- if eq $onlyCall.Function.Name "display_answers" -}}<|inner_suffix|>{{- $thinkingOpen = false -}}{{- end -}}
{{- end -}}
<|tools_prefix|>[
{{- range $j, $tc := $m.ToolCalls -}}
{{- if $j -}}, {{ end -}}
{"{{ $tc.Function.Name }}": {{ $tc.Function.Arguments | json }}}
{{- end -}}
]<|tools_suffix|>
{{- end -}}
{{- else if eq $m.Role "tool" -}}
{{- if not $inTool -}}[{{- $inTool = true -}}{{- else -}}, {{ end -}}
{{ $m.Content }}
{{- end -}}
{{- end -}}
{{- if $inTool -}}]{{- end -}}
<|assistant_start|>{{- "" -}}