|
"chat_template": "{%- set system_message_present = messages | selectattr('role', 'equalto', 'system') | list -%}{%- if not system_message_present -%}{%- set messages = [{ \"content\": \"You are an AI agent acting as a human assistant.\", \"role\": \"system\" }] + messages -%}{%- endif -%}{%- for message in messages -%}<|{{ message.role }}|>{{ '\n' }}{%- if message.role == 'system' -%}{{ message.content }}{%- if tools and tools | length > 0 -%}{{ '\n\n' }}You are aware of the following tools in your environment:{{ '\n' }}{\n \"tools\": [{{ '\n' }}{%- for tool in tools -%}{{ ' ' }}{\n \"function\": {\n \"description\": \"{{ tool.function.description }}\",{{ '\n' }} \"name\": \"{{ tool.function.name }}\",{{ '\n' }} \"parameters\": {{ tool.function.parameters | tojson }}{{ '\n' }} },{{ '\n' }} \"type\": \"{{ tool.type }}\"{{ '\n' }} }{%- if not loop.last -%},{%- endif -%}{{ '\n' }}{%- endfor -%}{{ ' ' }}]{{ '\n' }}}{{ '\n\n' }}If you would like to suggest one or more tool calls, please respond in the following format:{{ '\n' }}{\n \"finish_reason\": \"tool_calls\",{{ '\n' }} \"tool_calls\": [{{ '\n' }}{{ ' ' }}{\n \"arguments\": \"{\\\"parameter_name\\\": \\\"parameter_value\\\"}\",{{ '\n' }} \"id\": \"call_id\",{{ '\n' }} \"name\": \"tool_name\"{{ '\n' }} }{{ '\n' }} ]{{ '\n' }}}{%- endif -%}{{ eos_token }}{{ '\n' }}{%- endif -%}{%- if message.role == 'user' -%}{{ message.content }}{{ eos_token }}{{ '\n' }}{%- endif -%}{%- if message.role == 'assistant' -%}{% generation %}{%- if message.tool_calls and message.tool_calls | length > 0 -%}{\n \"finish_reason\": \"tool_calls\",{{ '\n' }} \"tool_calls\": [{{ '\n' }}{%- for tool_call in message.tool_calls -%}{{ ' ' }}{\n \"arguments\": {{ tool_call.function.arguments | tojson }},{{ '\n' }} \"id\": \"{{ tool_call.id }}\",{{ '\n' }} \"name\": \"{{ tool_call.function.name }}\"{{ '\n' }} }{%- if not loop.last -%},{%- endif -%}{{ '\n' }}{%- endfor -%}{{ ' ' }}]{{ '\n' }}}{%- else -%}{{ message.content }}{%- endif -%}{% endgeneration %}{{ eos_token }}{{ '\n' }}{%- endif -%}{%- if message.role == 'tool' -%}{\n \"content\": {{ message.content | tojson }},{{ '\n' }} \"name\": \"{{ message.name }}\",{{ '\n' }} \"tool_call_id\": \"{{ message.tool_call_id }}\"{{ '\n' }}}{{ eos_token }}{{ '\n' }}{%- endif -%}{%- endfor -%}{%- if add_generation_prompt -%}{{ '<|assistant|>\n' }}{%- endif -%}", |