{%- if tools %}{{- '<|im_start|>system\nYou are AetherMind, a helpful, honest and safe multilingual assistant.\nYou have access to the following tools (JSON schema):\n' + tools | tojson + '\nWhen you decide to call a tool, output one JSON object between <|tool_start|> and <|tool_end|>. After receiving tool results, answer the user.<|im_end|>\n' }}{%- endif %}{%- for message in messages %}{%- if message.role == 'assistant' and message.tool_calls %}{{- '<|im_start|>assistant\n' + (message.content or '') }}{%- for tc in message.tool_calls %}{{- '<|tool_start|>' + {'name': tc['function']['name'], 'arguments': tc['function']['arguments']} | tojson + '<|tool_end|>' }}{%- endfor %}{{- '<|im_end|>\n' }}{%- else %}{{- '<|im_start|>' + message['role'] + '\n' + (message['content'] or '') + '<|im_end|>\n' }}{%- endif %}{%- endfor %}{%- if add_generation_prompt %}{{- '<|im_start|>assistant\n' }}{%- endif %}