Text Generation
Transformers
Safetensors
PyTorch
English
llama
nvidia
unsloth
llama-3
conversational
text-generation-inference
Llama-3.1-Nemotron-Nano-4B-v1.1 / chat_template.jinja
danielhanchen's picture
Add files using upload-large-folder tool
6c7dac9 verified
{%- if tools %}{{- '<|begin_of_text|><|start_header_id|>system<|end_header_id|>
' -}}{%- if messages[0].role == 'system' -%}{{- messages[0].content + '
' -}}{%- endif -%}{{- '<AVAILABLE_TOOLS>[' -}}{%- for tool in tools -%}{{- (tool.function if tool.function is defined else tool) | tojson -}}{{- ', ' if not loop.last else '' -}}{%- endfor -%}{{- ']</AVAILABLE_TOOLS>' -}}{{- '<|eot_id|>' -}}{%- else %}{%- if messages[0].role == 'system' %}{{- '<|begin_of_text|><|start_header_id|>system<|end_header_id|>
' + messages[0].content + '<|eot_id|>' -}}{%- endif %}{%- endif %}{%- for message in messages -%}{%- if (message.role == 'user') -%}{{- '<|start_header_id|>user<|end_header_id|>
' + message.content + '<|eot_id|>' -}}{%- elif message.role == 'assistant' -%}{%- set content = message.content -%}{{- '<|start_header_id|>assistant<|end_header_id|>
' + content -}}{%- if message.tool_calls -%}{{- '<TOOLCALL>[' -}}{%- for tool_call in message.tool_calls -%}{%- if tool_call.function -%}{%- set tool_call = tool_call.function -%}{%- endif -%}{{- '{"name": "' }}{{- tool_call.name }}{{- '", "arguments": ' -}}{%- if tool_call.arguments is string -%}{{- tool_call.arguments -}}{%- else -%}{{- tool_call.arguments | tojson -}}{%- endif -%}{{- ', ' if not loop.last else '' -}}{%- endfor -%}{{- ']</TOOLCALL>' -}}{%- endif %}{{- '<|eot_id|>' -}}{%- elif message.role == 'tool' -%}{%- if loop.first or (messages[loop.index0 - 1].role != 'tool') -%}{{- '<|start_header_id|>user<|end_header_id|>
' }}{{- '<TOOL_RESPONSE>[' -}}{%- endif -%}{{- message.content -}}{{- ', ' if not loop.last and (messages[loop.index0 + 1].role == 'tool') else '' -}}{%- if loop.last or (messages[loop.index0 + 1].role != 'tool') -%}{{- ']</TOOL_RESPONSE>' -}}{{- '<|eot_id|>' -}}{%- endif %}{%- endif %}{%- endfor %}{%- if add_generation_prompt %}{{- '<|start_header_id|>assistant<|end_header_id|>
' -}}{%- endif %}