File size: 13,554 Bytes
ecd3d2c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
{
  "tokenizer_class": "PreTrainedTokenizerFast",
  "model_max_length": 16384,
  "bos_token": null,
  "eos_token": "<|im_end|>",
  "pad_token": "<|endoftext|>",
  "unk_token": null,
  "add_bos_token": false,
  "add_eos_token": false,
  "clean_up_tokenization_spaces": false,
  "added_tokens_decoder": {
    "0": {
      "content": "<|endoftext|>",
      "lstrip": false,
      "rstrip": false,
      "normalized": false,
      "single_word": false,
      "special": true
    },
    "1": {
      "content": "<|im_start|>",
      "lstrip": false,
      "rstrip": false,
      "normalized": false,
      "single_word": false,
      "special": true
    },
    "2": {
      "content": "<|im_end|>",
      "lstrip": false,
      "rstrip": false,
      "normalized": false,
      "single_word": false,
      "special": true
    },
    "3": {
      "content": "<think>",
      "lstrip": false,
      "rstrip": false,
      "normalized": false,
      "single_word": false,
      "special": false
    },
    "4": {
      "content": "</think>",
      "lstrip": false,
      "rstrip": false,
      "normalized": false,
      "single_word": false,
      "special": false
    },
    "5": {
      "content": "<tool_call>",
      "lstrip": false,
      "rstrip": false,
      "normalized": false,
      "single_word": false,
      "special": false
    },
    "6": {
      "content": "</tool_call>",
      "lstrip": false,
      "rstrip": false,
      "normalized": false,
      "single_word": false,
      "special": false
    },
    "7": {
      "content": "<tool_response>",
      "lstrip": false,
      "rstrip": false,
      "normalized": false,
      "single_word": false,
      "special": false
    },
    "8": {
      "content": "</tool_response>",
      "lstrip": false,
      "rstrip": false,
      "normalized": false,
      "single_word": false,
      "special": false
    },
    "9": {
      "content": "<|fim_prefix|>",
      "lstrip": false,
      "rstrip": false,
      "normalized": false,
      "single_word": false,
      "special": true
    },
    "10": {
      "content": "<|fim_middle|>",
      "lstrip": false,
      "rstrip": false,
      "normalized": false,
      "single_word": false,
      "special": true
    },
    "11": {
      "content": "<|fim_suffix|>",
      "lstrip": false,
      "rstrip": false,
      "normalized": false,
      "single_word": false,
      "special": true
    },
    "12": {
      "content": "<|file_sep|>",
      "lstrip": false,
      "rstrip": false,
      "normalized": false,
      "single_word": false,
      "special": true
    },
    "13": {
      "content": "<|repo_name|>",
      "lstrip": false,
      "rstrip": false,
      "normalized": false,
      "single_word": false,
      "special": true
    },
    "14": {
      "content": "<|reserved_0|>",
      "lstrip": false,
      "rstrip": false,
      "normalized": false,
      "single_word": false,
      "special": true
    },
    "15": {
      "content": "<|reserved_1|>",
      "lstrip": false,
      "rstrip": false,
      "normalized": false,
      "single_word": false,
      "special": true
    },
    "16": {
      "content": "<|reserved_2|>",
      "lstrip": false,
      "rstrip": false,
      "normalized": false,
      "single_word": false,
      "special": true
    },
    "17": {
      "content": "<|reserved_3|>",
      "lstrip": false,
      "rstrip": false,
      "normalized": false,
      "single_word": false,
      "special": true
    },
    "18": {
      "content": "<|reserved_4|>",
      "lstrip": false,
      "rstrip": false,
      "normalized": false,
      "single_word": false,
      "special": true
    },
    "19": {
      "content": "<|reserved_5|>",
      "lstrip": false,
      "rstrip": false,
      "normalized": false,
      "single_word": false,
      "special": true
    },
    "20": {
      "content": "<|reserved_6|>",
      "lstrip": false,
      "rstrip": false,
      "normalized": false,
      "single_word": false,
      "special": true
    },
    "21": {
      "content": "<|reserved_7|>",
      "lstrip": false,
      "rstrip": false,
      "normalized": false,
      "single_word": false,
      "special": true
    },
    "22": {
      "content": "<|reserved_8|>",
      "lstrip": false,
      "rstrip": false,
      "normalized": false,
      "single_word": false,
      "special": true
    },
    "23": {
      "content": "<|reserved_9|>",
      "lstrip": false,
      "rstrip": false,
      "normalized": false,
      "single_word": false,
      "special": true
    },
    "24": {
      "content": "<|reserved_10|>",
      "lstrip": false,
      "rstrip": false,
      "normalized": false,
      "single_word": false,
      "special": true
    },
    "25": {
      "content": "<|reserved_11|>",
      "lstrip": false,
      "rstrip": false,
      "normalized": false,
      "single_word": false,
      "special": true
    },
    "26": {
      "content": "<|reserved_12|>",
      "lstrip": false,
      "rstrip": false,
      "normalized": false,
      "single_word": false,
      "special": true
    },
    "27": {
      "content": "<|reserved_13|>",
      "lstrip": false,
      "rstrip": false,
      "normalized": false,
      "single_word": false,
      "special": true
    },
    "28": {
      "content": "<|reserved_14|>",
      "lstrip": false,
      "rstrip": false,
      "normalized": false,
      "single_word": false,
      "special": true
    },
    "29": {
      "content": "<|reserved_15|>",
      "lstrip": false,
      "rstrip": false,
      "normalized": false,
      "single_word": false,
      "special": true
    },
    "30": {
      "content": "<|reserved_16|>",
      "lstrip": false,
      "rstrip": false,
      "normalized": false,
      "single_word": false,
      "special": true
    },
    "31": {
      "content": "<|reserved_17|>",
      "lstrip": false,
      "rstrip": false,
      "normalized": false,
      "single_word": false,
      "special": true
    }
  },
  "chat_template": "{#- TinyBrainBot hybrid chat template (2026-11): Qwen3.8 structure (ChatML, XML tool calls, <tool_response>, hybrid <think>)\n    plus reasoning_effort. enable_thinking=false -> empty think block; enable_thinking=true -> opens <think>; unset -> the\n    model decides. reasoning_effort (low | medium | high) is stated in the system turn; \"none\" = no thinking. -#}\n{%- macro render_content(content) %}\n    {%- if content is string %}\n        {{- content }}\n    {%- elif content is iterable and content is not mapping %}\n        {%- for item in content %}\n            {%- if 'text' in item %}\n                {{- item.text }}\n            {%- endif %}\n        {%- endfor %}\n    {%- elif content is none or content is undefined %}\n        {{- '' }}\n    {%- endif %}\n{%- endmacro %}\n{%- if not messages %}\n    {{- raise_exception('No messages provided.') }}\n{%- endif %}\n{%- set effort = reasoning_effort if reasoning_effort is defined and reasoning_effort in ['none', 'low', 'medium', 'high'] else none %}\n{%- set effort_line = ('Reasoning effort: ' ~ effort) if effort and effort != 'none' else '' %}\n{%- set sys_content = render_content(messages[0].content)|trim if messages[0].role == 'system' else '' %}\n{%- if tools and tools is iterable and tools is not mapping %}\n    {{- '<|im_start|>system\\n' }}\n    {{- \"# Tools\\n\\nYou have access to the following functions:\\n\\n<tools>\" }}\n    {%- for tool in tools %}\n        {{- \"\\n\" }}\n        {{- tool | tojson }}\n    {%- endfor %}\n    {{- \"\\n</tools>\" }}\n    {{- '\\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<parameter=example_parameter_2>\\nThis is the value for the second parameter\\nthat can span\\nmultiple lines\\n</parameter>\\n</function>\\n</tool_call>\\n\\n<IMPORTANT>\\nReminder:\\n- Function calls MUST follow the specified format: an inner <function=...></function> block must be nested within <tool_call></tool_call> XML tags\\n- Required parameters MUST be specified\\n- You may provide optional reasoning for your function call in natural language BEFORE the function call, but NOT after\\n- If there is no function call available, answer the question like normal with your current knowledge and do not tell the user about function calls\\n</IMPORTANT>' }}\n    {%- if sys_content %}\n        {{- '\\n\\n' + sys_content }}\n    {%- endif %}\n    {%- if effort_line %}\n        {{- '\\n\\n' + effort_line }}\n    {%- endif %}\n    {{- '<|im_end|>\\n' }}\n{%- elif sys_content or effort_line %}\n    {{- '<|im_start|>system\\n' + sys_content }}\n    {%- if effort_line %}\n        {{- ('\\n\\n' if sys_content else '') + effort_line }}\n    {%- endif %}\n    {{- '<|im_end|>\\n' }}\n{%- endif %}\n{%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}\n{%- for message in messages[::-1] %}\n    {%- set index = (messages|length - 1) - loop.index0 %}\n    {%- if ns.multi_step_tool and message.role == \"user\" %}\n        {%- set content = render_content(message.content)|trim %}\n        {%- if not(content.startswith('<tool_response>') and content.endswith('</tool_response>')) %}\n            {%- set ns.multi_step_tool = false %}\n            {%- set ns.last_query_index = index %}\n        {%- endif %}\n    {%- endif %}\n{%- endfor %}\n{%- for message in messages %}\n    {%- set content = render_content(message.content)|trim %}\n    {%- if message.role == \"system\" %}\n        {%- if not loop.first %}\n            {{- raise_exception('System message must be at the beginning.') }}\n        {%- endif %}\n    {%- elif message.role == \"user\" %}\n        {{- '<|im_start|>' + message.role + '\\n' + content + '<|im_end|>' + '\\n' }}\n    {%- elif message.role == \"assistant\" %}\n        {%- set reasoning_content = '' %}\n        {%- if message.reasoning_content is string %}\n            {%- set reasoning_content = message.reasoning_content %}\n        {%- else %}\n            {%- if '</think>' in content %}\n                {%- set reasoning_content = content.split('</think>')[0].rstrip('\\n').split('<think>')[-1].lstrip('\\n') %}\n                {%- set content = content.split('</think>')[-1].lstrip('\\n') %}\n            {%- endif %}\n        {%- endif %}\n        {%- set reasoning_content = reasoning_content|trim %}\n        {%- if loop.index0 > ns.last_query_index %}\n            {{- '<|im_start|>' + message.role + '\\n<think>\\n' + reasoning_content + '\\n</think>\\n\\n' + content }}\n        {%- else %}\n            {{- '<|im_start|>' + message.role + '\\n' + content }}\n        {%- endif %}\n        {%- if message.tool_calls and message.tool_calls is iterable and message.tool_calls is not mapping %}\n            {%- for tool_call in message.tool_calls %}\n                {%- if tool_call.function is defined %}\n                    {%- set tool_call = tool_call.function %}\n                {%- endif %}\n                {%- if loop.first %}\n                    {%- if content|trim %}\n                        {{- '\\n\\n<tool_call>\\n<function=' + tool_call.name + '>\\n' }}\n                    {%- else %}\n                        {{- '<tool_call>\\n<function=' + tool_call.name + '>\\n' }}\n                    {%- endif %}\n                {%- else %}\n                    {{- '\\n<tool_call>\\n<function=' + tool_call.name + '>\\n' }}\n                {%- endif %}\n                {%- if tool_call.arguments is defined %}\n                    {%- for args_name, args_value in tool_call.arguments|items %}\n                        {{- '<parameter=' + args_name + '>\\n' }}\n                        {%- set args_value = args_value | tojson | safe if args_value is mapping or (args_value is sequence and args_value is not string) else args_value | string %}\n                        {{- args_value }}\n                        {{- '\\n</parameter>\\n' }}\n                    {%- endfor %}\n                {%- endif %}\n                {{- '</function>\\n</tool_call>' }}\n            {%- endfor %}\n        {%- endif %}\n        {{- '<|im_end|>\\n' }}\n    {%- elif message.role == \"tool\" %}\n        {%- if loop.previtem and loop.previtem.role != \"tool\" %}\n            {{- '<|im_start|>user' }}\n        {%- endif %}\n        {{- '\\n<tool_response>\\n' }}\n        {{- content }}\n        {{- '\\n</tool_response>' }}\n        {%- if not loop.last and loop.nextitem.role != \"tool\" %}\n            {{- '<|im_end|>\\n' }}\n        {%- elif loop.last %}\n            {{- '<|im_end|>\\n' }}\n        {%- endif %}\n    {%- else %}\n        {{- raise_exception('Unexpected message role.') }}\n    {%- endif %}\n{%- endfor %}\n{%- if add_generation_prompt %}\n    {{- '<|im_start|>assistant\\n' }}\n    {#- 2026-11-09: thinking is OFF by default (Qwen3.8-style). Turn it on with enable_thinking=true or reasoning_effort\n        low/medium/high. \"Model decides\" (no think block forced) made the 53M think on every prompt and skip tools. #}\n    {%- if (enable_thinking is defined and enable_thinking is true) or (effort and effort != 'none') %}\n        {{- '<think>\\n' }}\n    {%- else %}\n        {{- '<think>\\n\\n</think>\\n\\n' }}\n    {%- endif %}\n{%- endif %}\n"
}