Qwen3.5
2026/03/02 9B〜0.8Bまで追加
2026/02/25 122〜27Bまで追加
2026/02/16今の所公式に発表があったのは397B(実サイズ403B?)のみ
全モデルvlm化しており始めから(VLモデルを別途待たずに)画像認識が可能になっている ←前
全体を書き換えなくても下記の内容を追加するだけでthinkのON/OFFを切り替えれるようだ
部分抜粋版、下記のブロックの後に追加する
{%- if not messages %}
{{- raise_exception('No messages provided.') }}
{%- endif %}
code:QWEN3.5.thinkaddjinja
{#- ===== /think システムプロンプトフラグで切り替え ===== -#}
{%- set ns_flags = namespace(enable_thinking=false) %}
{%- if messages and messages0.role == 'system' %} {%- set sys_text_check = render_content(messages0.content, false, true) | string %} {%- if '/think' in sys_text_check %}
{%- set ns_flags.enable_thinking = true %}
{%- endif %}
{%- endif %}
{%- set enable_thinking = ns_flags.enable_thinking %}
{#- ===================================================== -#}
全体版
code:QWEN3.5.MOD.jinja
{%- set image_count = namespace(value=0) %}
{%- set video_count = namespace(value=0) %}
{%- macro render_content(content, do_vision_count, is_system_content=false) %}
{%- if content is string %}
{{- content }}
{%- elif content is iterable and content is not mapping %}
{%- for item in content %}
{%- if 'image' in item or 'image_url' in item or item.type == 'image' %}
{%- if is_system_content %}
{{- raise_exception('System message cannot contain images.') }}
{%- endif %}
{%- if do_vision_count %}
{%- set image_count.value = image_count.value + 1 %}
{%- endif %}
{{- '<|vision_start|><|image_pad|><|vision_end|>' }}
{%- elif 'video' in item or item.type == 'video' %}
{%- if is_system_content %}
{{- raise_exception('System message cannot contain videos.') }}
{%- endif %}
{%- if do_vision_count %}
{%- set video_count.value = video_count.value + 1 %}
{%- endif %}
{{- '<|vision_start|><|video_pad|><|vision_end|>' }}
{%- elif 'text' in item %}
{{- item.text }}
{%- else %}
{{- raise_exception('Unexpected item type in content.') }}
{%- endif %}
{%- endfor %}
{%- elif content is none or content is undefined %}
{{- '' }}
{%- else %}
{{- raise_exception('Unexpected content type.') }}
{%- endif %}
{%- endmacro %}
{%- if not messages %}
{{- raise_exception('No messages provided.') }}
{%- endif %}
{# ========================================= #} {# Detect /think ONLY in FIRST system msg #} {# ========================================= #} {%- set ns_enable = namespace(enable_thinking=false) %}
{%- if messages0.role == 'system' %} {%- set sys_raw = render_content(messages0.content, false, true)|trim %} {%- if '/think' in sys_raw %}
{%- set ns_enable.enable_thinking = true %}
{%- endif %}
{%- endif %}
{%- if tools and tools is iterable and tools is not mapping %}
{{- '<|im_start|>system\n' }}
{{- "# Tools\n\nYou have access to the following functions:\n\n<tools>" }}
{%- for tool in tools %}
{{- "\n" }}
{{- tool | tojson }}
{%- endfor %}
{{- "\n</tools>" }}
{%- if messages0.role == 'system' %} {%- set content = render_content(messages0.content, false, true)|trim %} {%- set content = content.replace('/think','')|trim %}
{%- if content %}
{{- '\n\n' + content }}
{%- endif %}
{%- endif %}
{{- '<|im_end|>\n' }}
{%- else %}
{%- if messages0.role == 'system' %} {%- set content = render_content(messages0.content, false, true)|trim %} {%- set content = content.replace('/think','')|trim %}
{{- '<|im_start|>system\n' + content + '<|im_end|>\n' }}
{%- endif %}
{%- endif %}
{%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}
{%- for message in messages::-1 %} {%- set index = (messages|length - 1) - loop.index0 %}
{%- if ns.multi_step_tool and message.role == "user" %}
{%- set content = render_content(message.content, false)|trim %}
{%- if not(content.startswith('<tool_response>') and content.endswith('</tool_response>')) %}
{%- set ns.multi_step_tool = false %}
{%- set ns.last_query_index = index %}
{%- endif %}
{%- endif %}
{%- endfor %}
{%- if ns.multi_step_tool %}
{{- raise_exception('No user query found in messages.') }}
{%- endif %}
{%- for message in messages %}
{%- set content = render_content(message.content, true)|trim %}
{%- if message.role == "system" %}
{%- if not loop.first %}
{{- raise_exception('System message must be at the beginning.') }}
{%- endif %}
{%- elif message.role == "user" %}
{{- '<|im_start|>user\n' + content + '<|im_end|>\n' }}
{%- elif message.role == "assistant" %}
{{- '<|im_start|>assistant\n' }}
{%- if ns_enable.enable_thinking and loop.index0 > ns.last_query_index %}
{%- if message.reasoning_content %}
{{- '<think>\n' + message.reasoning_content|trim + '\n</think>\n\n' }}
{%- endif %}
{%- endif %}
{{- content }}
{{- '<|im_end|>\n' }}
{%- elif message.role == "tool" %}
{{- '<|im_start|>user\n<tool_response>\n' }}
{{- content }}
{{- '\n</tool_response><|im_end|>\n' }}
{%- else %}
{{- raise_exception('Unexpected message role.') }}
{%- endif %}
{%- endfor %}
{# ========================================= #} {# Final generation prompt control #} {# ========================================= #} {%- if add_generation_prompt %}
{{- '<|im_start|>assistant\n' }}
{%- if ns_enable.enable_thinking %}
{{- '<think>\n' }}
{%- else %}
{{- '<think>\n</think>\n\n' }}
{%- endif %}
{%- endif %}