darkc0de commited on
Commit
54d319f
·
verified ·
1 Parent(s): afeaf74

Upload tokenizer_config.json

Browse files
Files changed (1) hide show
  1. tokenizer_config.json +1 -1
tokenizer_config.json CHANGED
@@ -297,5 +297,5 @@
297
  "special": true
298
  }
299
  },
300
- "chat_template": "{%- set template_version = \"qwen3.8-safe-v3.1\" %}\n{#- -------------------------------------------------------------------------\n Whitespace contract: every tag opener in this file carries a leading minus,\n so it strips the whitespace and newlines that precede it. All emitted text\n comes from string literals, which makes the rendered prompt byte-exact and\n free of incidental newlines. Comment tags need the minus just as much as\n block tags do; a plain comment tag breaks the strip chain and leaks the\n surrounding indentation into the prompt.\n ------------------------------------------------------------------------- -#}\n{#- The message list has to exist before anything else can inspect it. -#}\n{%- if not messages %}\n {{- raise_exception('No messages provided.') }}\n{%- endif %}\n{#- -------------------------------------------------------------------------\n Configuration\n ------------------------------------------------------------------------- -#}\n{%- set _requested_tool_format =\n tool_call_format if tool_call_format is defined else 'xml'\n%}\n{%- if _requested_tool_format not in ('auto', 'xml', 'json') %}\n {{- raise_exception(\n 'Unexpected tool_call_format ' ~ _requested_tool_format ~\n '. Supported values are xml (default), auto, and json.'\n ) }}\n{%- endif %}\n{%- set add_vision_id = add_vision_id if add_vision_id is defined else false %}\n{%- set enable_thinking = enable_thinking if enable_thinking is defined else true %}\n{%- set auto_disable_thinking_with_tools =\n auto_disable_thinking_with_tools\n if auto_disable_thinking_with_tools is defined\n else false\n%}\n{%- if preserve_reasoning is defined\n and preserve_reasoning is not none\n and preserve_thinking is defined\n and preserve_thinking is not none\n and preserve_reasoning != preserve_thinking %}\n {{- raise_exception(\n 'preserve_reasoning and preserve_thinking were both provided with conflicting values.'\n ) }}\n{%- endif %}\n{%- if preserve_reasoning is defined and preserve_reasoning is not none %}\n {%- set _preserve_thinking = preserve_reasoning %}\n{%- elif preserve_thinking is defined and preserve_thinking is not none %}\n {%- set _preserve_thinking = preserve_thinking %}\n{%- else %}\n {%- set _preserve_thinking = true %}\n{%- endif %}\n{%- set max_tool_arg_chars =\n max_tool_arg_chars if max_tool_arg_chars is defined else 0\n%}\n{%- set max_tool_response_chars =\n max_tool_response_chars if max_tool_response_chars is defined else 0\n%}\n{%- if max_tool_arg_chars is not number or max_tool_arg_chars < 0 %}\n {{- raise_exception('max_tool_arg_chars must be a non-negative number.') }}\n{%- endif %}\n{%- if max_tool_response_chars is not number or max_tool_response_chars < 0 %}\n {{- raise_exception('max_tool_response_chars must be a non-negative number.') }}\n{%- endif %}\n{%- if tools is defined and tools is not none and tools %}\n {%- if tools is string or tools is mapping or tools is not iterable %}\n {{- raise_exception('tools must be an iterable list of tool definitions.') }}\n {%- endif %}\n {%- set _has_tools = true %}\n{%- else %}\n {%- set _has_tools = false %}\n{%- endif %}\n{#- -------------------------------------------------------------------------\n Resolve the tool-call wire format.\n\n OpenAI-compatible servers hand assistant tool calls back with\n `function.arguments` as a JSON *string*, not a mapping. The XML parameter\n form needs the individual key/value pairs, and a chat template cannot\n decode a JSON string: the standard chat-template environment provides\n `tojson` but no inverse, and no codepoint-to-character primitive, so a\n hand-rolled scanner could not decode \\uXXXX escapes correctly. Guessing\n would silently corrupt tool arguments, which is worse than any error.\n\n The deployment-safe default is XML, matching Qwen's native tool-call wire\n format and the qwen3_coder tool parser. A caller can explicitly request\n tool_call_format='auto' to render the whole prompt in JSON form whenever a\n historical tool call carries string arguments. That path is lossless,\n needs no decoding, and keeps the system-prompt instructions and rendered\n history in one consistent format. Histories whose arguments are all\n mappings still render as XML, byte-identically to tool_call_format='xml'.\n\n A caller that uses the default XML mode (or explicitly pins 'xml') still\n gets a hard error for non-empty string arguments, because that request\n cannot be honoured faithfully in the native XML parameter representation.\n ------------------------------------------------------------------------- -#}\n{%- set format_scan = namespace(has_json_string_arguments=false) %}\n{%- for message in messages %}\n {%- if message.role == 'assistant'\n and message.tool_calls is defined\n and message.tool_calls is not none\n and message.tool_calls\n and message.tool_calls is not string\n and message.tool_calls is not mapping\n and message.tool_calls is iterable %}\n {%- for tool_call in message.tool_calls %}\n {%- if tool_call.function is defined\n and tool_call.function is not none %}\n {%- set _tc = tool_call.function %}\n {%- else %}\n {%- set _tc = tool_call %}\n {%- endif %}\n {%- if _tc.arguments is defined\n and _tc.arguments is not none\n and _tc.arguments is string\n and _tc.arguments | trim\n and _tc.arguments | trim != '{}' %}\n {%- set format_scan.has_json_string_arguments = true %}\n {%- endif %}\n {%- endfor %}\n {%- endif %}\n{%- endfor %}\n{%- if _requested_tool_format == 'auto' %}\n {%- if format_scan.has_json_string_arguments %}\n {%- set _tool_format = 'json' %}\n {%- else %}\n {%- set _tool_format = 'xml' %}\n {%- endif %}\n{%- else %}\n {%- set _tool_format = _requested_tool_format %}\n{%- endif %}\n{%- set _thinking_enabled = enable_thinking %}\n{%- if auto_disable_thinking_with_tools and _has_tools %}\n {%- set _thinking_enabled = false %}\n{%- endif %}\n{#- Normalize and validate reasoning effort even when thinking is disabled.\n Explicit null follows the template default; OpenAI-style `minimal` maps to\n low, while `none` disables thinking for this render. -#}\n{%- if reasoning_effort is undefined or reasoning_effort is none %}\n {%- set _effort_raw = 'medium' %}\n{%- else %}\n {%- set _effort_raw = reasoning_effort %}\n{%- endif %}\n{%- if _effort_raw == 'none' %}\n {%- set _thinking_enabled = false %}\n {%- set _reasoning_effort = 'xhigh' %}\n{%- elif _effort_raw == 'high' or _effort_raw == 'xhigh' %}\n {%- set _reasoning_effort = 'xhigh' %}\n{%- elif _effort_raw == 'medium' %}\n {%- set _reasoning_effort = 'medium' %}\n{%- elif _effort_raw == 'minimal' or _effort_raw == 'low' %}\n {%- set _reasoning_effort = 'low' %}\n{%- else %}\n {{- raise_exception(\n 'Unexpected reasoning effort ' ~ _effort_raw ~\n '. Supported values are none, minimal/low, medium, and high/xhigh; null uses the medium default.'\n ) }}\n{%- endif %}\n{%- set reasoning_instructions = '' %}\n{%- if _thinking_enabled %}\n {%- if _reasoning_effort == 'xhigh' %}\n {%- set reasoning_instructions =\n 'Reasoning effort is set to xhigh. Please think carefully through the task, validate key assumptions, consider plausible alternatives, and prioritize correctness, consistency, and clarity in the final answer.'\n %}\n {%- elif _reasoning_effort == 'low' %}\n {%- set reasoning_instructions =\n 'Reasoning effort is set to low. Keep your thinking brief and focused, moving directly to the conclusion without unnecessary elaboration.'\n %}\n {%- endif %}\n{%- endif %}\n{#- -------------------------------------------------------------------------\n Content rendering\n ------------------------------------------------------------------------- -#}\n{%- set image_count = namespace(value=0) %}\n{%- set video_count = namespace(value=0) %}\n{%- macro render_content(content, do_vision_count, is_system_content=false) %}\n {%- if content is string %}\n {{- content }}\n {%- elif content is iterable and content is not mapping %}\n {%- for item in content %}\n {%- if item is not mapping %}\n {{- raise_exception(\n 'Content-list items must be mappings with a supported text, image, or video type.'\n ) }}\n {%- endif %}\n {%- set _item_type = item.type if 'type' in item else none %}\n {%- if _item_type is not none\n and _item_type not in ('text', 'image', 'image_url', 'video') %}\n {{- raise_exception(\n 'Unexpected content item type ' ~ _item_type ~ '.'\n ) }}\n {%- endif %}\n {%- set _is_image =\n _item_type == 'image'\n or _item_type == 'image_url'\n or 'image' in item\n or 'image_url' in item\n %}\n {%- set _is_video =\n _item_type == 'video'\n or 'video' in item\n %}\n {%- if _is_image and _is_video %}\n {{- raise_exception(\n 'A content item cannot contain both image and video data.'\n ) }}\n {%- elif _item_type == 'text' and (_is_image or _is_video) %}\n {{- raise_exception(\n 'A text content item cannot also contain image or video data.'\n ) }}\n {%- elif _is_image %}\n {%- if is_system_content %}\n {{- raise_exception(\n 'System and developer messages cannot contain images.'\n ) }}\n {%- endif %}\n {%- if do_vision_count %}\n {%- set image_count.value = image_count.value + 1 %}\n {%- endif %}\n {%- if add_vision_id %}\n {{- 'Picture ' ~ image_count.value ~ ': ' }}\n {%- endif %}\n {{- '<|vision_start|><|image_pad|><|vision_end|>' }}\n {%- elif _is_video %}\n {%- if is_system_content %}\n {{- raise_exception(\n 'System and developer messages cannot contain videos.'\n ) }}\n {%- endif %}\n {%- if do_vision_count %}\n {%- set video_count.value = video_count.value + 1 %}\n {%- endif %}\n {%- if add_vision_id %}\n {{- 'Video ' ~ video_count.value ~ ': ' }}\n {%- endif %}\n {{- '<|vision_start|><|video_pad|><|vision_end|>' }}\n {%- elif _item_type == 'text' or 'text' in item %}\n {%- if 'text' not in item or item.text is not string %}\n {{- raise_exception(\n 'Text content items must contain a string text field.'\n ) }}\n {%- endif %}\n {{- item.text }}\n {%- else %}\n {{- raise_exception(\n 'Unexpected item in content list. Expected text, image, or video content.'\n ) }}\n {%- endif %}\n {%- endfor %}\n {%- elif content is none or content is undefined %}\n {{- '' }}\n {%- else %}\n {{- raise_exception('Unexpected content type.') }}\n {%- endif %}\n{%- endmacro %}\n{#- -------------------------------------------------------------------------\n Validate and merge leading system/developer messages\n ------------------------------------------------------------------------- -#}\n{%- set head = namespace(count=0, seen_non_system=false) %}\n{%- for message in messages %}\n {%- set _is_system =\n message.role == 'system' or message.role == 'developer'\n %}\n {%- if _is_system %}\n {%- if head.seen_non_system %}\n {{- raise_exception(\n 'System and developer messages must appear before all user, assistant, and tool messages.'\n ) }}\n {%- endif %}\n {%- set head.count = head.count + 1 %}\n {%- else %}\n {%- set head.seen_non_system = true %}\n {%- endif %}\n{%- endfor %}\n{%- set system_state = namespace(content='') %}\n{%- for message in messages[:head.count] %}\n {%- set _part =\n render_content(message.content, false, true) | trim\n %}\n {%- if _part %}\n {%- if system_state.content %}\n {%- set system_state.content =\n system_state.content ~ '\\n\\n' ~ _part\n %}\n {%- else %}\n {%- set system_state.content = _part %}\n {%- endif %}\n {%- endif %}\n{%- endfor %}\n{%- set _system_content = system_state.content %}\n{%- set _msgs = messages[head.count:] %}\n{#- -------------------------------------------------------------------------\n System prompt and tool instructions\n ------------------------------------------------------------------------- -#}\n{%- if _has_tools %}\n {{- '<|im_start|>system\\n' }}\n {%- if reasoning_instructions %}\n {{- reasoning_instructions ~ '\\n\\n' }}\n {%- endif %}\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 {%- if _tool_format == 'json' %}\n {{- '\\n\\nIf you choose to call a function ONLY reply in the following format with NO suffix:\\n\\n<tool_call>\\n{\"name\": \"example_function_name\", \"arguments\": {\"example_parameter_1\": \"value_1\", \"example_parameter_2\": \"This is the value for the second parameter\"}}\\n</tool_call>\\n\\n<IMPORTANT>\\nReminder:\\n- Function calls MUST follow the specified format: a single JSON object with \"name\" and \"arguments\" keys 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 {%- else %}\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 {%- endif %}\n {%- if _system_content %}\n {{- '\\n\\n' ~ _system_content }}\n {%- endif %}\n {{- '<|im_end|>\\n' }}\n{%- else %}\n {%- if _system_content %}\n {{- '<|im_start|>system\\n'\n ~ (reasoning_instructions ~ '\\n\\n' if reasoning_instructions else '')\n ~ _system_content\n ~ '<|im_end|>\\n'\n }}\n {%- elif reasoning_instructions %}\n {{- '<|im_start|>system\\n'\n ~ reasoning_instructions\n ~ '<|im_end|>\\n'\n }}\n {%- endif %}\n{%- endif %}\n{#- -------------------------------------------------------------------------\n Find the last real user query\n ------------------------------------------------------------------------- -#}\n{%- set ns = namespace(\n multi_step_tool=true,\n last_query_index=(_msgs | length) - 1\n) %}\n{%- for message in _msgs[::-1] %}\n {%- set index = (_msgs | length - 1) - loop.index0 %}\n {%- if ns.multi_step_tool and message.role == 'user' %}\n {%- set _rendered_user =\n render_content(message.content, false) | trim\n %}\n {%- if not (\n _rendered_user.startswith('<tool_response>')\n and _rendered_user.endswith('</tool_response>')\n ) %}\n {%- set ns.multi_step_tool = false %}\n {%- set ns.last_query_index = index %}\n {%- endif %}\n {%- endif %}\n{%- endfor %}\n{%- if ns.multi_step_tool %}\n {{- raise_exception('No user query found in messages.') }}\n{%- endif %}\n{#- -------------------------------------------------------------------------\n Conversation rendering\n ------------------------------------------------------------------------- -#}\n{%- set history_state = namespace(previous_role='') %}\n{%- for message in _msgs %}\n {%- set content =\n render_content(message.content, true) | trim\n %}\n {%- if message.role == 'user' %}\n {{- '<|im_start|>user\\n'\n ~ content\n ~ '<|im_end|>\\n'\n }}\n {%- elif message.role == 'assistant' %}\n {%- set reasoning_content = '' %}\n {#- Prefer current vLLM's `reasoning` field, then retain compatibility\n with older `reasoning_content` and other servers' `thinking`. -#}\n {%- if message.reasoning is defined\n and message.reasoning is not none %}\n {%- if message.reasoning is string %}\n {%- set reasoning_content = message.reasoning %}\n {%- else %}\n {%- set reasoning_content =\n message.reasoning | string\n %}\n {%- endif %}\n {%- elif message.reasoning_content is defined\n and message.reasoning_content is not none %}\n {%- if message.reasoning_content is string %}\n {%- set reasoning_content = message.reasoning_content %}\n {%- else %}\n {%- set reasoning_content =\n message.reasoning_content | string\n %}\n {%- endif %}\n {%- elif message.thinking is defined\n and message.thinking is not none %}\n {%- if message.thinking is string %}\n {%- set reasoning_content = message.thinking %}\n {%- else %}\n {%- set reasoning_content =\n message.thinking | string\n %}\n {%- endif %}\n {%- endif %}\n {%- set reasoning_content = reasoning_content | trim %}\n {#- Preserve the original invariant: when thinking is preserved,\n always reconstruct the thinking block, even when it is empty. -#}\n {%- if _preserve_thinking\n or loop.index0 > ns.last_query_index %}\n {{- '<|im_start|>assistant\\n<think>\\n'\n ~ reasoning_content\n ~ '\\n</think>\\n\\n'\n ~ content\n }}\n {%- else %}\n {{- '<|im_start|>assistant\\n' ~ content }}\n {%- endif %}\n {%- if message.tool_calls is defined\n and message.tool_calls is not none\n and message.tool_calls %}\n {%- if message.tool_calls is string\n or message.tool_calls is mapping\n or message.tool_calls is not iterable %}\n {{- raise_exception(\n 'assistant.tool_calls must be an iterable list of tool calls.'\n ) }}\n {%- endif %}\n {%- for tool_call in message.tool_calls %}\n {%- if tool_call.function is defined\n and tool_call.function is not none %}\n {%- set tc = tool_call.function %}\n {%- else %}\n {%- set tc = tool_call %}\n {%- endif %}\n {%- if tc.name is not defined\n or tc.name is none\n or tc.name is not string\n or not tc.name %}\n {{- raise_exception(\n 'Every tool call must have a non-empty string name.'\n ) }}\n {%- endif %}\n {%- set tc_name = tc.name %}\n {%- if _tool_format == 'json' %}\n {%- if loop.first %}\n {%- if content | trim %}\n {{- '\\n\\n<tool_call>\\n' }}\n {%- else %}\n {{- '<tool_call>\\n' }}\n {%- endif %}\n {%- else %}\n {{- '\\n<tool_call>\\n' }}\n {%- endif %}\n {%- set _json_arguments = '{}' %}\n {%- if tc.arguments is defined\n and tc.arguments is not none %}\n {%- if tc.arguments is mapping %}\n {%- set _json_arguments =\n tc.arguments | tojson\n %}\n {%- elif tc.arguments is string %}\n {%- set _raw_arguments =\n tc.arguments | trim\n %}\n {%- if _raw_arguments %}\n {%- if not (\n _raw_arguments.startswith('{')\n and _raw_arguments.endswith('}')\n ) %}\n {{- raise_exception(\n 'JSON tool-call arguments must be a JSON object string.'\n ) }}\n {%- endif %}\n {%- set _json_arguments =\n _raw_arguments\n %}\n {%- endif %}\n {%- else %}\n {{- raise_exception(\n 'JSON tool-call arguments must be a mapping or a JSON object string.'\n ) }}\n {%- endif %}\n {%- endif %}\n {{- '{\"name\": ' }}\n {{- tc_name | tojson }}\n {{- ', \"arguments\": ' }}\n {{- _json_arguments }}\n {{- '}\\n</tool_call>' }}\n {%- else %}\n {%- if loop.first %}\n {%- if content | trim %}\n {{- '\\n\\n<tool_call>\\n<function='\n ~ tc_name\n ~ '>\\n'\n }}\n {%- else %}\n {{- '<tool_call>\\n<function='\n ~ tc_name\n ~ '>\\n'\n }}\n {%- endif %}\n {%- else %}\n {{- '\\n<tool_call>\\n<function='\n ~ tc_name\n ~ '>\\n'\n }}\n {%- endif %}\n {%- if tc.arguments is defined\n and tc.arguments is not none %}\n {%- if tc.arguments is mapping %}\n {%- for args_name, args_value\n in tc.arguments | items %}\n {%- set _argument_name =\n args_name | string\n %}\n {{- '<parameter='\n ~ _argument_name\n ~ '>\\n'\n }}\n {#- Preserve strings verbatim. Serialize every\n other type as JSON so booleans and null stay\n true/false/null instead of True/False/None. -#}\n {%- if args_value is string %}\n {%- set _argument_value =\n args_value\n %}\n {%- else %}\n {%- set _argument_value =\n args_value | tojson\n %}\n {%- endif %}\n {%- if max_tool_arg_chars > 0\n and _argument_value | length\n > max_tool_arg_chars %}\n {{- _argument_value[:max_tool_arg_chars] }}\n {{- '\\n[TRUNCATED — original length '\n ~ (_argument_value | length | string)\n ~ ' chars]'\n }}\n {%- else %}\n {{- _argument_value }}\n {%- endif %}\n {{- '\\n</parameter>\\n' }}\n {%- endfor %}\n {%- elif tc.arguments is string %}\n {%- set _raw_arguments =\n tc.arguments | trim\n %}\n {%- if _raw_arguments\n and _raw_arguments != '{}' %}\n {{- raise_exception(\n 'tool_call_format=\"xml\" requires tool-call arguments to be mappings, but received a JSON string. Parse the JSON string into a mapping before applying the template, or set tool_call_format=\"auto\" (or \"json\") to use the lossless JSON tool-call representation.'\n ) }}\n {%- endif %}\n {%- else %}\n {{- raise_exception(\n 'XML tool-call arguments must be a mapping. Parse JSON-string arguments before applying the template.'\n ) }}\n {%- endif %}\n {%- endif %}\n {{- '</function>\\n</tool_call>' }}\n {%- endif %}\n {%- endfor %}\n {%- endif %}\n {{- '<|im_end|>\\n' }}\n {%- elif message.role == 'tool' %}\n {%- if history_state.previous_role != 'tool' %}\n {{- '<|im_start|>user' }}\n {%- endif %}\n {%- if max_tool_response_chars > 0\n and content | length > max_tool_response_chars %}\n {%- set content =\n content[:max_tool_response_chars]\n ~ '\\n[TRUNCATED — original length '\n ~ (content | length | string)\n ~ ' chars]'\n %}\n {%- endif %}\n {{- '\\n<tool_response>\\n' }}\n {{- content }}\n {{- '\\n</tool_response>' }}\n {%- if loop.last %}\n {{- '<|im_end|>\\n' }}\n {%- elif _msgs[loop.index0 + 1].role != 'tool' %}\n {{- '<|im_end|>\\n' }}\n {%- endif %}\n {%- elif message.role == 'system'\n or message.role == 'developer' %}\n {{- raise_exception(\n 'System and developer messages must appear only at the beginning of the conversation.'\n ) }}\n {%- else %}\n {{- raise_exception(\n 'Unexpected message role ' ~ message.role ~ '.'\n ) }}\n {%- endif %}\n {%- set history_state.previous_role = message.role %}\n{%- endfor %}\n{#- -------------------------------------------------------------------------\n Generation prompt\n ------------------------------------------------------------------------- -#}\n{%- if add_generation_prompt %}\n {{- '<|im_start|>assistant\\n' }}\n {%- if not _thinking_enabled %}\n {{- '<think>\\n\\n</think>\\n\\n' }}\n {%- else %}\n {{- '<think>\\n' }}\n {%- endif %}\n{%- endif %}"
301
  }
 
297
  "special": true
298
  }
299
  },
300
+ "chat_template": "{%- set template_version = \"darkc0de_xortron_JAX_testing.v14\" %}\n{%- set _tool_format = tool_call_format if tool_call_format is defined else 'xml' %}\n{%- set image_count = namespace(value=0) %}\n{%- set video_count = namespace(value=0) %}\n{%- set add_vision_id = add_vision_id if add_vision_id is defined else false %}\n{%- set enable_thinking = enable_thinking if enable_thinking is defined else true %}\n{%- set auto_disable_thinking_with_tools = auto_disable_thinking_with_tools if auto_disable_thinking_with_tools is defined else false %}\n{%- if preserve_reasoning is defined and preserve_reasoning is not none %}\n {%- set _preserve_thinking = preserve_reasoning %}\n{%- elif preserve_thinking is defined and preserve_thinking is not none %}\n {%- set _preserve_thinking = preserve_thinking %}\n{%- else %}\n {%- set _preserve_thinking = true %}\n{%- endif %}\n{%- set max_tool_arg_chars = max_tool_arg_chars if max_tool_arg_chars is defined else 0 %}\n{%- set max_tool_response_chars = max_tool_response_chars if max_tool_response_chars is defined else 0 %}\n{%- set _default_reasoning_effort = 'medium' %}\n{%- set _has_tools = (tools is defined and tools and tools is iterable and tools is not mapping) %}\n{%- set _effort_raw = (reasoning_effort | string | lower) if reasoning_effort is defined and reasoning_effort is not none else _default_reasoning_effort %}\n{%- set _initial_thinking = enable_thinking %}\n{%- if _effort_raw in ('none', 'off') %}\n {%- set _initial_thinking = false %}\n {%- set _initial_effort = 'medium' %}\n{%- elif _effort_raw in ('minimal', 'low') %}\n {%- set _initial_effort = 'low' %}\n{%- elif _effort_raw in ('high', 'xhigh', 'max', 'ultracode', 'extreme') %}\n {%- set _initial_effort = 'xhigh' %}\n{%- else %}\n {%- set _initial_effort = 'medium' %}\n{%- endif %}\n{%- set ns_state = namespace(thinking=_initial_thinking, effort=_initial_effort) %}\n{%- if auto_disable_thinking_with_tools and _has_tools %}\n {%- set ns_state.thinking = false %}\n{%- endif %}\n{%- for msg in messages %}\n {%- if msg.role == 'system' or msg.role == 'developer' or msg.role == 'user' %}\n {%- if msg.content is string %}\n {%- if '<|think_off|>' in msg.content %}\n {%- set ns_state.thinking = false %}\n {%- elif '<|think_on|>' in msg.content %}\n {%- set ns_state.thinking = true %}\n {%- elif '<|think_xhigh|>' in msg.content or '<|think_high|>' in msg.content or '<|think_ultracode|>' in msg.content or '<|think_extreme|>' in msg.content or '<|think_max|>' in msg.content %}\n {%- set ns_state.thinking = true %}\n {%- set ns_state.effort = 'xhigh' %}\n {%- elif '<|think_low|>' in msg.content or '<|think_minimal|>' in msg.content %}\n {%- set ns_state.thinking = true %}\n {%- set ns_state.effort = 'low' %}\n {%- elif '<|think_medium|>' in msg.content %}\n {%- set ns_state.thinking = true %}\n {%- set ns_state.effort = 'medium' %}\n {%- endif %}\n {%- elif msg.content is iterable and msg.content is not mapping %}\n {%- for item in msg.content %}\n {%- if item is string %}\n {%- set _item_text = item %}\n {%- elif item is mapping and 'text' in item and item.text is string %}\n {%- set _item_text = item.text %}\n {%- else %}\n {%- set _item_text = '' %}\n {%- endif %}\n {%- if _item_text %}\n {%- if '<|think_off|>' in _item_text %}\n {%- set ns_state.thinking = false %}\n {%- elif '<|think_on|>' in _item_text %}\n {%- set ns_state.thinking = true %}\n {%- elif '<|think_xhigh|>' in _item_text or '<|think_high|>' in _item_text or '<|think_ultracode|>' in _item_text or '<|think_extreme|>' in _item_text or '<|think_max|>' in _item_text %}\n {%- set ns_state.thinking = true %}\n {%- set ns_state.effort = 'xhigh' %}\n {%- elif '<|think_low|>' in _item_text or '<|think_minimal|>' in _item_text %}\n {%- set ns_state.thinking = true %}\n {%- set ns_state.effort = 'low' %}\n {%- elif '<|think_medium|>' in _item_text %}\n {%- set ns_state.thinking = true %}\n {%- set ns_state.effort = 'medium' %}\n {%- endif %}\n {%- endif %}\n {%- endfor %}\n {%- endif %}\n {%- endif %}\n{%- endfor %}\n{%- set reasoning_instructions = '' %}\n{%- if ns_state.thinking %}\n {%- if ns_state.effort == 'xhigh' %}\n {%- set reasoning_instructions = 'Reasoning effort is set to xhigh. Please think carefully through the task, validate key assumptions, consider plausible alternatives, and prioritize correctness, consistency, and clarity in the final answer.' %}\n {%- elif ns_state.effort == 'low' %}\n {%- set reasoning_instructions = 'Reasoning effort is set to low. Keep your thinking brief and focused, moving directly to the conclusion without unnecessary elaboration.' %}\n {%- endif %}\n{%- endif %}\n{%- macro render_content(content, do_vision_count, is_system_content=false) %}\n {%- if content is string %}\n {{- content }}\n {%- elif content is iterable and content is not mapping %}\n {%- for item in content %}\n {%- if item is mapping %}\n {%- if item.type == 'image' or 'image' in item or 'image_url' in item %}\n {%- if is_system_content %}\n {{- raise_exception('System message cannot contain images.') }}\n {%- endif %}\n {%- if do_vision_count %}\n {%- set image_count.value = image_count.value + 1 %}\n {%- endif %}\n {%- if add_vision_id %}\n {{- 'Picture ' ~ image_count.value ~ ': ' }}\n {%- endif %}\n {{- '<|vision_start|><|image_pad|><|vision_end|>' }}\n {%- elif item.type == 'video' or 'video' in item %}\n {%- if is_system_content %}\n {{- raise_exception('System message cannot contain videos.') }}\n {%- endif %}\n {%- if do_vision_count %}\n {%- set video_count.value = video_count.value + 1 %}\n {%- endif %}\n {%- if add_vision_id %}\n {{- 'Video ' ~ video_count.value ~ ': ' }}\n {%- endif %}\n {{- '<|vision_start|><|video_pad|><|vision_end|>' }}\n {%- elif 'text' in item %}\n {{- item.text }}\n {%- else %}\n {{- raise_exception('Unexpected item type in content.') }}\n {%- endif %}\n {%- else %}\n {{- item | string }}\n {%- endif %}\n {%- endfor %}\n {%- elif content is none or content is undefined %}\n {{- '' }}\n {%- else %}\n {{- raise_exception('Unexpected content type.') }}\n {%- endif %}\n{%- endmacro %}\n{%- if not messages %}\n {{- raise_exception('No messages provided.') }}\n{%- endif %}\n{%- set head = namespace(count=0, seen_non_system=false) %}\n{%- for message in messages %}\n {%- set _is_sys = (message.role == 'system' or message.role == 'developer') %}\n {%- if _is_sys and not head.seen_non_system %}\n {%- set head.count = head.count + 1 %}\n {%- else %}\n {%- set head.seen_non_system = true %}\n {%- endif %}\n{%- endfor %}\n{%- set sys_state = namespace(content='') %}\n{%- for message in messages[:head.count] %}\n {%- set _part = render_content(message.content, false, true) | trim %}\n {%- if '<|think_off|>' in _part %}{%- set _part = _part.split('<|think_off|>') | join('') | trim %}{%- endif %}\n {%- if '<|think_on|>' in _part %}{%- set _part = _part.split('<|think_on|>') | join('') | trim %}{%- endif %}\n {%- if '<|think_xhigh|>' in _part %}{%- set _part = _part.split('<|think_xhigh|>') | join('') | trim %}{%- endif %}\n {%- if '<|think_high|>' in _part %}{%- set _part = _part.split('<|think_high|>') | join('') | trim %}{%- endif %}\n {%- if '<|think_ultracode|>' in _part %}{%- set _part = _part.split('<|think_ultracode|>') | join('') | trim %}{%- endif %}\n {%- if '<|think_extreme|>' in _part %}{%- set _part = _part.split('<|think_extreme|>') | join('') | trim %}{%- endif %}\n {%- if '<|think_max|>' in _part %}{%- set _part = _part.split('<|think_max|>') | join('') | trim %}{%- endif %}\n {%- if '<|think_medium|>' in _part %}{%- set _part = _part.split('<|think_medium|>') | join('') | trim %}{%- endif %}\n {%- if '<|think_low|>' in _part %}{%- set _part = _part.split('<|think_low|>') | join('') | trim %}{%- endif %}\n {%- if '<|think_minimal|>' in _part %}{%- set _part = _part.split('<|think_minimal|>') | join('') | trim %}{%- endif %}\n {%- if _part %}\n {%- if sys_state.content %}\n {%- set sys_state.content = sys_state.content ~ '\\n\\n' ~ _part %}\n {%- else %}\n {%- set sys_state.content = _part %}\n {%- endif %}\n {%- endif %}\n{%- endfor %}\n{%- set _sc = sys_state.content %}\n{%- set _msgs = messages[head.count:] %}\n{%- if _has_tools %}\n {{- '<|im_start|>system\\n' }}\n {%- if reasoning_instructions %}\n {{- reasoning_instructions + '\\n\\n' }}\n {%- endif %}\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 {%- if _tool_format == 'json' %}\n {{- '\\n\\nIf you choose to call a function ONLY reply in the following format with NO suffix:\\n\\n<think>\\nBrief explanation of tool call\\n</think>\\n<tool_call>\\n{\"name\": \"example_function_name\", \"arguments\": {\"example_parameter_1\": \"value_1\", \"example_parameter_2\": \"This is the value for the second parameter\"}}\\n</tool_call>\\n\\n<IMPORTANT>\\nReminder:\\n- You can use the <think></think> block to plan your next tool call OR to synthesize data and formulate your final response to the user.\\n- ALL explanation and reasoning MUST be placed strictly inside the <think></think> block.\\n- Function calls MUST follow the specified format: a single JSON object with \"name\" and \"arguments\" keys inside <tool_call></tool_call> XML tags.\\n- If you choose to call a tool, you MUST output the <tool_call> block IMMEDIATELY after thinking, with NO conversational text before it.\\n- The <tool_call> tag MUST be at the very beginning of a new line, with NO spaces or indentation before it.\\n- To call multiple functions, output a separate, completely closed <tool_call></tool_call> block for EACH function. Do NOT nest <tool_call> blocks.\\n- If you have all necessary data, provide your final answer directly to the user without any tool call.\\n</IMPORTANT>' }}\n {%- else %}\n {{- '\\n\\nIf you choose to call a function ONLY reply in the following format with NO suffix:\\n\\n<think>\\nBrief explanation of tool call\\n</think>\\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- You can use the <think></think> block to plan your next tool call OR to synthesize data and formulate your final response to the user.\\n- ALL explanation and reasoning MUST be placed strictly inside the <think></think> block.\\n- Function calls MUST follow the specified format: an inner <function=...></function> block must be nested within <tool_call></tool_call> XML tags.\\n- If you choose to call a tool, you MUST output the <tool_call> block IMMEDIATELY after thinking, with NO conversational text before it.\\n- The <tool_call> and <function> tags MUST be at the very beginning of a new line, with NO spaces or indentation before them.\\n- To call multiple functions, output a separate, completely closed <tool_call></tool_call> block for EACH function. Do NOT nest <tool_call> blocks.\\n- If you have all necessary data, provide your final answer directly to the user without any tool call.\\n</IMPORTANT>' }}\n {%- endif %}\n {%- if _sc %}\n {{- '\\n\\n' + _sc }}\n {%- endif %}\n {{- '<|im_end|>\\n' }}\n{%- else %}\n {%- if _sc %}\n {{- '<|im_start|>system\\n' + (reasoning_instructions + '\\n\\n' if reasoning_instructions else '') + _sc + '<|im_end|>\\n' }}\n {%- elif reasoning_instructions %}\n {{- '<|im_start|>system\\n' + reasoning_instructions + '<|im_end|>\\n' }}\n {%- endif %}\n{%- endif %}\n{%- set _last_idx = _msgs | length - 1 %}\n{%- set ns = namespace(multi_step_tool=true, last_query_index=_last_idx) %}\n{%- for message in _msgs[::-1] %}\n {%- set index = (_msgs | length - 1) - loop.index0 %}\n {%- if ns.multi_step_tool and message.role == 'user' %}\n {%- set _rc = render_content(message.content, false) | trim %}\n {%- if not (_rc.startswith('<tool_response>') and _rc.endswith('</tool_response>')) %}\n {%- set ns.multi_step_tool = false %}\n {%- set ns.last_query_index = index %}\n {%- endif %}\n {%- endif %}\n{%- endfor %}\n{%- if ns.multi_step_tool %}\n {%- if _last_idx > 50 %}\n {%- set ns.last_query_index = _last_idx %}\n {%- else %}\n {%- set ns.last_query_index = 0 %}\n {%- endif %}\n{%- endif %}\n{%- set ns2 = namespace(prev_role='', consecutive_failures=0) %}\n{%- for message in _msgs %}\n {%- set is_system = (message.role == \"system\" or message.role == \"developer\") %}\n {%- set content = render_content(message.content, true, is_system) | trim %}\n {%- if is_system or message.role == 'user' %}\n {%- if '<|think_off|>' in content %}{%- set content = content.split('<|think_off|>') | join('') | trim %}{%- endif %}\n {%- if '<|think_on|>' in content %}{%- set content = content.split('<|think_on|>') | join('') | trim %}{%- endif %}\n {%- if '<|think_xhigh|>' in content %}{%- set content = content.split('<|think_xhigh|>') | join('') | trim %}{%- endif %}\n {%- if '<|think_high|>' in content %}{%- set content = content.split('<|think_high|>') | join('') | trim %}{%- endif %}\n {%- if '<|think_ultracode|>' in content %}{%- set content = content.split('<|think_ultracode|>') | join('') | trim %}{%- endif %}\n {%- if '<|think_extreme|>' in content %}{%- set content = content.split('<|think_extreme|>') | join('') | trim %}{%- endif %}\n {%- if '<|think_max|>' in content %}{%- set content = content.split('<|think_max|>') | join('') | trim %}{%- endif %}\n {%- if '<|think_medium|>' in content %}{%- set content = content.split('<|think_medium|>') | join('') | trim %}{%- endif %}\n {%- if '<|think_low|>' in content %}{%- set content = content.split('<|think_low|>') | join('') | trim %}{%- endif %}\n {%- if '<|think_minimal|>' in content %}{%- set content = content.split('<|think_minimal|>') | join('') | trim %}{%- endif %}\n {%- endif %}\n {%- if is_system %}\n {{- '<|im_start|>system\\n' + content + '<|im_end|>\\n' }}\n {%- elif message.role == 'user' %}\n {%- set ns2.consecutive_failures = 0 %}\n {{- '<|im_start|>user\\n' + content + '<|im_end|>\\n' }}\n {%- elif message.role == 'assistant' %}\n {%- set reasoning_content = '' %}\n {%- set _explicit_reasoning = '' %}\n {%- if message.reasoning_content is defined and message.reasoning_content is not none %}\n {%- if message.reasoning_content is string %}\n {%- set _explicit_reasoning = message.reasoning_content %}\n {%- else %}\n {%- set _explicit_reasoning = message.reasoning_content | string %}\n {%- endif %}\n {%- elif message.thinking is defined and message.thinking is not none %}\n {%- if message.thinking is string %}\n {%- set _explicit_reasoning = message.thinking %}\n {%- else %}\n {%- set _explicit_reasoning = message.thinking | string %}\n {%- endif %}\n {%- elif message.reasoning is defined and message.reasoning is not none %}\n {%- if message.reasoning is string %}\n {%- set _explicit_reasoning = message.reasoning %}\n {%- else %}\n {%- set _explicit_reasoning = message.reasoning | string %}\n {%- endif %}\n {%- endif %}\n {%- if _explicit_reasoning %}\n {%- set _lead_end = '' %}\n {%- if content.startswith('<think>') and '</think>' in content %}\n {%- set _lead_end = '</think>' %}\n {%- elif content.startswith('<thinking>') and '</thinking>' in content %}\n {%- set _lead_end = '</thinking>' %}\n {%- elif content.startswith('</think>') %}\n {%- set _lead_end = '</think>' %}\n {%- elif content.startswith('</thinking>') %}\n {%- set _lead_end = '</thinking>' %}\n {%- endif %}\n {%- if _lead_end %}\n {%- set content = content.split(_lead_end)[-1].lstrip('\\n') %}\n {%- endif %}\n {%- set reasoning_content = _explicit_reasoning %}\n {%- else %}\n {%- set _think_end = '' %}\n {%- if content.startswith('</think>') %}\n {%- set _think_end = '</think>' %}\n {%- elif content.startswith('</thinking>') %}\n {%- set _think_end = '</thinking>' %}\n {%- elif '\\n</think>' in content %}\n {%- set _think_end = '\\n</think>' %}\n {%- elif '\\n</thinking>' in content %}\n {%- set _think_end = '\\n</thinking>' %}\n {%- elif '\\n</ think>' in content %}\n {%- set _think_end = '\\n</ think>' %}\n {%- elif '\\n</think >' in content %}\n {%- set _think_end = '\\n</think >' %}\n {%- elif content.startswith('<think>') and '</think>' in content %}\n {%- set _think_end = '</think>' %}\n {%- elif content.startswith('<thinking>') and '</thinking>' in content %}\n {%- set _think_end = '</thinking>' %}\n {%- endif %}\n {%- if _think_end %}\n {%- if 'thinking' in _think_end %}\n {%- set _think_start = '<thinking>' %}\n {%- else %}\n {%- set _think_start = '<think>' %}\n {%- endif %}\n {%- set reasoning_content = content.split(_think_end)[0].rstrip('\\n') %}\n {%- if _think_start in reasoning_content %}\n {%- set reasoning_content = reasoning_content.split(_think_start)[-1].lstrip('\\n') %}\n {%- endif %}\n {%- set content = content.split(_think_end)[-1].lstrip('\\n') %}\n {%- endif %}\n {%- endif %}\n {%- set reasoning_content = reasoning_content | trim %}\n {%- if (_preserve_thinking or loop.index0 > ns.last_query_index) %}\n {{- '<|im_start|>assistant\\n<think>\\n' + reasoning_content + '\\n</think>\\n\\n' + content }}\n {%- else %}\n {{- '<|im_start|>assistant\\n' + content }}\n {%- endif %}\n {%- if message.tool_calls is defined and 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 and tool_call.function is not none %}\n {%- set tc = tool_call.function %}\n {%- else %}\n {%- set tc = tool_call %}\n {%- endif %}\n {%- set tc_name = tc.name if (tc.name is defined and tc.name is not none) else '' %}\n {%- if _tool_format == 'json' %}\n {%- if loop.first %}\n {%- if content | trim %}\n {{- '\\n\\n' }}\n {%- endif %}\n {%- else %}\n {{- '\\n' }}\n {%- endif %}\n {%- set _args = '{}' %}\n {%- if tc.arguments is defined and tc.arguments is not none %}\n {%- if tc.arguments is mapping %}\n {%- set _args = tc.arguments | tojson %}\n {%- elif tc.arguments is string %}\n {%- if tc.arguments %}\n {%- set _args = tc.arguments %}\n {%- endif %}\n {%- else %}\n {%- set _args = tc.arguments | tojson %}\n {%- endif %}\n {%- endif %}\n {{- '<tool_call>\\n{\"name\": ' }}{{- tc_name | tojson }}{{- ', \"arguments\": ' }}{{- _args }}{{- '}\\n</tool_call>' }}\n {%- else %}\n {%- if loop.first %}\n {%- if content | trim %}\n {{- '\\n\\n<tool_call>\\n<function=' + tc_name + '>\\n' }}\n {%- else %}\n {{- '<tool_call>\\n<function=' + tc_name + '>\\n' }}\n {%- endif %}\n {%- else %}\n {{- '\\n<tool_call>\\n<function=' + tc_name + '>\\n' }}\n {%- endif %}\n {%- if tc.arguments is defined and tc.arguments is not none %}\n {%- if tc.arguments is mapping %}\n {%- for args_name, args_value in tc.arguments.items() %}\n {{- '<parameter=' + args_name + '>\\n' }}\n {%- if args_value is string %}\n {%- set _av = args_value %}\n {%- else %}\n {%- set _av = args_value | tojson %}\n {%- endif %}\n {%- if max_tool_arg_chars > 0 and _av | length > max_tool_arg_chars %}\n {{- _av[:max_tool_arg_chars] + '\\n[TRUNCATED - original length ' ~ (_av | length | string) ~ ' chars]' }}\n {%- else %}\n {{- _av }}\n {%- endif %}\n {{- '\\n</parameter>\\n' }}\n {%- endfor %}\n {%- else %}\n {%- if tc.arguments is string %}\n {%- set _raw_args = tc.arguments %}\n {%- else %}\n {%- set _raw_args = tc.arguments | tojson %}\n {%- endif %}\n {%- if _raw_args %}\n {%- if max_tool_arg_chars > 0 and _raw_args | length > max_tool_arg_chars %}\n {{- _raw_args[:max_tool_arg_chars] + '\\n[TRUNCATED - original length ' ~ (_raw_args | length | string) ~ ' chars]' }}\n {%- else %}\n {{- _raw_args }}\n {%- endif %}\n {%- endif %}\n {%- endif %}\n {%- endif %}\n {{- '</function>\\n</tool_call>' }}\n {%- endif %}\n {%- endfor %}\n {%- endif %}\n {{- '<|im_end|>\\n' }}\n {%- elif message.role == 'tool' %}\n {%- set _content_lower = content | lower %}\n {%- set _content_head = _content_lower[:120] %}\n {%- set _is_code_or_grep = ('throw new ' in _content_lower or 'throw error' in _content_lower or 'console.error' in _content_lower or 'logger.error' in _content_lower or 'logging.error' in _content_lower or 'import ' in _content_head or 'def ' in _content_head or 'function ' in _content_head) %}\n {%- set _exit_code_zero = ('exit code: 0' in _content_head or 'process exited with code 0' in _content_head) %}\n {%- set _error_field_ok = ('\"error\": null' in _content_head or '\"error\":null' in _content_head or '\"error\": false' in _content_head or '\"error\":false' in _content_head or '\"error\": \"\"' in _content_head or '\"error\":\"\"' in _content_head) %}\n {%- set _strong_error = (('\"error\":' in _content_head and not _error_field_ok) or '\"status\": \"error\"' in _content_head or '\"status\":\"error\"' in _content_head or 'traceback (most recent call last):' in _content_head or 'command not found' in _content_head or 'invalid syntax' in _content_head or 'fatal:' in _content_head or (('exit code: ' in _content_head or 'process exited with code' in _content_head) and not _exit_code_zero) or _content_head.startswith('exception:') or _content_head.startswith('failed to ')) %}\n {%- set _weak_error = ('error:' in _content_head or 'err!' in _content_head) %}\n {%- set _weak_suppressed = ('$ ' in _content_head or 'took ' in _content_head or content | length >= 600) %}\n {%- if not _is_code_or_grep and (_strong_error or (_weak_error and not _weak_suppressed)) %}\n {%- set ns2.consecutive_failures = ns2.consecutive_failures + 1 %}\n {%- else %}\n {%- set ns2.consecutive_failures = 0 %}\n {%- endif %}\n {%- if ns2.prev_role != 'tool' %}\n {{- '<|im_start|>user' }}\n {%- endif %}\n {%- if _tool_format != 'json' and max_tool_response_chars > 0 and content | length > max_tool_response_chars %}\n {%- set content = content[:max_tool_response_chars] + '\\n[TRUNCATED - original length ' ~ (content | length | string) ~ ' chars]' %}\n {%- endif %}\n {{- '\\n<tool_response>\\n' + content }}\n {%- if ns2.consecutive_failures >= 2 %}\n {{- '\\n\\n⚠️ SYSTEM WARNING: ' ~ ns2.consecutive_failures ~ ' consecutive tool errors detected. Your previous approach is incorrect. You MUST use a fundamentally different approach or corrected arguments.' }}\n {%- elif ns2.consecutive_failures == 1 %}\n {{- '\\n\\n⚠️ SYSTEM WARNING: The previous tool call returned an error. Diagnose the failure and retry with completely corrected arguments.' }}\n {%- endif %}\n {{- '\\n</tool_response>' }}\n {%- if loop.last %}\n {{- '<|im_end|>\\n' }}\n {%- else %}\n {%- set _next_role = _msgs[loop.index0 + 1].role %}\n {%- if _next_role != 'tool' %}\n {{- '<|im_end|>\\n' }}\n {%- endif %}\n {%- endif %}\n {%- else %}\n {{- '<|im_start|>user\\n[' + message.role + ']: ' + content + '<|im_end|>\\n' }}\n {%- endif %}\n {%- set ns2.prev_role = message.role %}\n{%- endfor %}\n{%- if add_generation_prompt %}\n {{- '<|im_start|>assistant\\n' }}\n {%- if not ns_state.thinking %}\n {{- '<think>\\n\\n</think>\\n\\n' }}\n {%- else %}\n {{- '<think>\\n' }}\n {%- endif %}\n{%- endif %}"
301
  }