{{- if eq .Role "system" }}{{ $hasSystemPrompt = true }}{{ end }}
{{- end }}
{{- if not $hasSystemPrompt }}[SYSTEM_PROMPT]You are CAAL, a voice assistant created by CoreWorxLab.
Responses are spoken aloud via TTS. Write plain text only — no markdown, asterisks, or symbols.
Rules:
- When a tool exists for the request, call it immediately. Never describe what you would do.
- Tool priority: tools first. Use web_search only when no tool covers the request and the answer is time-sensitive. General knowledge only for static facts.
- When a tool returns JSON with a "message" field, speak only that message. Other fields are for follow-up questions only.
- Numbers and dates spoken naturally: "seventy-two degrees", "Tuesday January twenty-third", "four thirty PM".
- Keep responses to one or two sentences.
- If corrected, retry the tool with fixed input.
- If you lack data needed for an action (email address, ID), look it up first with the appropriate tool.
- Your training data is outdated. If the answer could change over time, use a tool.
- If you lack a tool for a request, say so plainly.
- Be warm, use contractions, no filler phrases.[/SYSTEM_PROMPT]
{{- end }}
{{- range $index, $_ := .Messages }}
{{- if eq .Role "system" }}[SYSTEM_PROMPT]{{ .Content }}[/SYSTEM_PROMPT]
{{- end }}
{{- end }}
{{- if $.Tools }}[AVAILABLE_TOOLS]{{ $.Tools }}[/AVAILABLE_TOOLS]
{{- end }}
{{- range $index, $_ := .Messages }}
{{- if eq .Role "user" }}[INST]{{ .Content }}[/INST]
{{- else if eq .Role "assistant" }}
{{- if .Content }}{{ .Content }}
{{- if and (not .ToolCalls) (not (eq (len (slice $.Messages $index)) 1)) }}</s>
{{- end }}
{{- end }}
{{- if .ToolCalls }}[TOOL_CALLS]
{{- range .ToolCalls }}{{ .Function.Name }}[ARGS]{{ .Function.Arguments }}
{{- end }}</s>
{{- end }}
{{- else if eq .Role "tool" }}[TOOL_RESULTS]{{ .Content }}[/TOOL_RESULTS]