{ "chat_template": "{% macro render_content(content) %} {% if content is string %}{{- content }}{% elif content is mapping %}{{- content['value'] if 'value' in content else content['text'] }}{% elif content is iterable %}{% for item in content %}{% if item.type == 'text' %}{{- item['value'] if 'value' in item else item['text'] }}{% elif item.type == 'image' %}{% endif %}{% endfor %}{% endif %} {% endmacro %}{% if not add_generation_prompt is defined %}{% set add_generation_prompt = false %}{% endif %}{{ bos_token }}{% for message in messages %}{% if message.role == 'system' %}{{ render_content(message['content']) }}{% endif %}{% endfor %}{% if tools is defined and tools %}{% set ns = namespace(data='') %}{% for tool in tools %}{% set ns.data = ns.data + (tool | tojson(ensure_ascii=False)) + '\n' %}{% endfor %}{% set tool_schemas_var = ns.data %}# Tools \nYou may call one or more tools to assist with the user query. You are provided with tool schemas within XML tags: {{ tool_schemas_var }} When making tool calls, use XML format to invoke tools and pass parameters: <|tool_calls_begin|>\n<|tool_call_begin|>\nfunction<|tool_sep|>[parameter value]...<|tool_call_end|>\n<|tool_call_begin|>\nfunction<|tool_sep|>[parameter value]...<|tool_call_end|>\n<|tool_calls_end|>\nNote: * You can invoke one or more tools in parallel. * Each tool call must be complete and self-contained within a single block. {% endif %}{% for message in messages %}{% if message.role == 'tool_description' %}{{ render_content(message['content']) }}{% elif message.role == 'user' %}{{- '<|BOT|>' + message.role + '\\n' + render_content(message['content']) }}{{- '<|EOT|>' }}{% elif message.role == 'tool_response' %}<|tool_outputs_begin|>\n{% for tool_output in message['content'] %}<|tool_output_begin|>\n{{ render_content(tool_output) }}<|tool_output_end|>{% endfor %}\n<|tool_outputs_end|>\n{% else %}{{- '<|BOT|>' + message.role + '\n' }}{% if message['content'] is defined %}{{- render_content(message['content']) }}{% endif %}{% if message.tool_calls is defined %}<|tool_calls_begin|>\n{% for tool in message.tool_calls %}<|tool_call_begin>|>\n{{ tool['type'] }}<|tool_sep|>{{- '' }}{% for name, param in tool['function']['arguments'].items() %} {{- '' + param | string + '' }}{% endfor %}<|tool_call_end|>\n{% endfor %}<|tool_calls_end|>\n{% endif %}<|EOT|>{% endif %}{% endfor %}{% if add_generation_prompt %}{{- '<|BOT|>assistant\n\n' }}{% endif %}" }