Crystalcareai commited on
Commit
80973c7
·
verified ·
1 Parent(s): 44bc97d

Update chat_template.jinja

Browse files
Files changed (1) hide show
  1. chat_template.jinja +16 -5
chat_template.jinja CHANGED
@@ -98,13 +98,24 @@
98
  {%- if role == "assistant" %}
99
  {%- set content_str = '' if message.content is none else (message.content | string) %}
100
  {%- set trimmed_content = content_str | trim %}
 
101
  {%- set has_reasoning_content = message.reasoning_content is defined %}
 
 
 
 
 
 
 
 
 
 
102
  {%- set has_tool_calls = message.tool_calls is defined and message.tool_calls is iterable and message.tool_calls is not string and message.tool_calls | length > 0 %}
103
 
104
  {{- '<|im_start|>assistant\n' }}
105
- {%- if has_reasoning_content %}
106
- {%- if message.reasoning_content %}
107
- {{- '<think>' + (message.reasoning_content | string | trim) + '</think>' }}
108
  {%- else %}
109
  {{- '<think></think>' }}
110
  {%- endif %}
@@ -121,7 +132,7 @@
121
 
122
  {%- if has_tool_calls %}
123
  {%- for tool_call in message.tool_calls %}
124
- {%- set separator = '\n' if ((loop.first and (has_reasoning_content or trimmed_content)) or (not loop.first)) else '' -%}
125
  {{- separator + render_tool_call(tool_call) }}
126
  {%- endfor %}
127
  {%- endif %}
@@ -145,4 +156,4 @@
145
 
146
  {%- if add_generation_prompt %}
147
  {{- '<|im_start|>assistant\n<think>' }}
148
- {%- endif %}
 
98
  {%- if role == "assistant" %}
99
  {%- set content_str = '' if message.content is none else (message.content | string) %}
100
  {%- set trimmed_content = content_str | trim %}
101
+
102
  {%- set has_reasoning_content = message.reasoning_content is defined %}
103
+ {%- set has_reasoning = has_reasoning_content or (message.reasoning is defined) %}
104
+
105
+ {%- if has_reasoning_content %}
106
+ {%- set reasoning_value = message.reasoning_content %}
107
+ {%- elif message.reasoning is defined %}
108
+ {%- set reasoning_value = message.reasoning %}
109
+ {%- else %}
110
+ {%- set reasoning_value = none %}
111
+ {%- endif %}
112
+
113
  {%- set has_tool_calls = message.tool_calls is defined and message.tool_calls is iterable and message.tool_calls is not string and message.tool_calls | length > 0 %}
114
 
115
  {{- '<|im_start|>assistant\n' }}
116
+ {%- if has_reasoning %}
117
+ {%- if reasoning_value %}
118
+ {{- '<think>' + (reasoning_value | string | trim) + '</think>' }}
119
  {%- else %}
120
  {{- '<think></think>' }}
121
  {%- endif %}
 
132
 
133
  {%- if has_tool_calls %}
134
  {%- for tool_call in message.tool_calls %}
135
+ {%- set separator = '\n' if ((loop.first and (has_reasoning or trimmed_content)) or (not loop.first)) else '' -%}
136
  {{- separator + render_tool_call(tool_call) }}
137
  {%- endfor %}
138
  {%- endif %}
 
156
 
157
  {%- if add_generation_prompt %}
158
  {{- '<|im_start|>assistant\n<think>' }}
159
+ {%- endif %}