Darwin-28B-NEG / chat_template.jinja
SeaWolf-AI's picture
Initial Darwin-28B-NEG release (base + NEG-Head + NEG-Gate)
c3d7133 verified
Raw
History Blame Contribute Delete
2.15 kB
{%- if not messages %}
{{- raise_exception('No messages provided.') }}
{%- endif %}
{%- if tools and tools is iterable and tools is not mapping %}
{{- '<|im_start|>system
' }}
{{- "# Tools\n\nYou have access to the following functions:\n\n<tools>" }}
{%- for tool in tools %}
{{- "\n" }}
{{- tool | tojson }}
{%- endfor %}
{{- "\n</tools>" }}
{{- '\n\nIf you choose to call a function ONLY reply in the following format with NO suffix:\n\n<tool_call>\n<function=example_function_name>\n<parameter=example_parameter_1>\nvalue_1\n</parameter>\n</function>\n</tool_call>\n\n<IMPORTANT>\nReminder:\n- Function calls MUST follow the specified format\n- Required parameters MUST be specified\n- If there is no function call available, answer normally\n</IMPORTANT>' }}
{%- if messages[0].role == 'system' %}
{{- '\n\n' + messages[0].content | trim + '<|im_end|>\n' }}
{%- else %}
{{- '<|im_end|>\n' }}
{%- endif %}
{%- else %}
{%- if messages[0].role == 'system' %}
{{- '<|im_start|>system\n' + messages[0].content | trim + '<|im_end|>\n' }}
{%- endif %}
{%- endif %}
{%- set ns = namespace(last_query_index=messages|length - 1) %}
{%- for message in messages %}
{%- if message.role == "user" %}
{{- '<|im_start|>user\n' + message.content | trim + '<|im_end|>\n' }}
{%- elif message.role == "assistant" %}
{%- set content = message.content | trim %}
{%- set reasoning = '' %}
{%- if '</think>' in content %}
{%- set reasoning = content.split('</think>')[0].split('<think>')[-1].strip() %}
{%- set content = content.split('</think>')[-1].strip() %}
{%- endif %}
{{- '<|im_start|>assistant\n' }}
{%- if reasoning %}
{{- '<think>\n' + reasoning + '\n</think>\n\n' }}
{%- endif %}
{{- content + '<|im_end|>\n' }}
{%- elif message.role == "tool" %}
{{- '<tool_response>\n' + message.content | trim + '\n</tool_response>\n' }}
{%- endif %}
{%- endfor %}
{%- if add_generation_prompt %}
{{- '<|im_start|>assistant\n<think>\n' }}
{%- endif %}