{{ bos_token }} {%- if tools %} <|turn>system You have tools available. To call a tool, respond with: {"name": "FUNCTION_NAME", "arguments": {JSON_ARGS}} Available tools: {%- for t in tools %} - {{ t.function.name }}: {{ t.function.description }} Parameters: {{ t.function.parameters | tojson }} {%- endfor %} {%- endif %} {%- for m in messages %} {%- if m.role == 'user' %} <|turn>user {{ m.content }} {%- elif m.role == 'assistant' or m.role == 'model' %} <|turn>model {%- if m.tool_calls %} {%- for tc in m.tool_calls %} {"name": "{{ tc.function.name }}", "arguments": {{ tc.function.arguments | tojson }}} {%- endfor %} {%- endif %} {%- if m.content %} {{ m.content }}{%- endif %} {%- elif m.role == 'tool' %} <|turn>tool {{ m.content }} {%- endif %} {%- endfor %} {%- if add_generation_prompt %} <|turn>model {% endif %}