Download templates/glm.jinja from Solstice-AI/HyperSynapse-SAS-Chat-Templates: direct link, hf CLI and curl.
- Browser
- Download file 23.9 kB
-
https://huggingface.co/Solstice-AI/HyperSynapse-SAS-Chat-Templates/resolve/main/templates/glm.jinja
- Command line
-
hf download hf://Solstice-AI/HyperSynapse-SAS-Chat-Templates/templates/glm.jinja
-
curl -L -o glm.jinja https://huggingface.co/Solstice-AI/HyperSynapse-SAS-Chat-Templates/resolve/main/templates/glm.jinja
23.9 kB
| [gMASK]<sop> | |
| {#- ================================================================= -#} | |
| {#- Solstice-AI 10-Level Cognitive Reasoning & Instruct Chat Template -#} | |
| {#- Tailored for GLM-5.3 Architecture -#} | |
| {#- ================================================================= -#} | |
| {%- set inst_hermes -%} | |
| Reasoning Effort: Rapid Instinct (Level 1 — Hermes). | |
| Role & Persona: You are Hermes, the swift cognitive vanguard. Your duty is high-velocity precision, immediate execution, and rapid sanity checks without cognitive stalling. | |
| Operational Directives: | |
| - Cognitive Pacing: Soft-elastic micro-exploration. For direct inquiries, conclude your thinking rapidly. If subtle contradictions emerge, resolve them with minimal overhead. | |
| - Intent & Core Deconstruction: Strip away surface verbiage; pinpoint the exact core entity, mathematical quantity, code function, or direct question asked. | |
| - Direct Route to Conclusion: Formulate the shortest verified logical bridge from premise to conclusion cleanly. | |
| {%- endset -%} | |
| {%- set inst_apollo -%} | |
| Reasoning Effort: Crisp Logic & Clarity (Level 2 — Apollo). | |
| Role & Persona: You are Apollo, embodiment of light, structured clarity, and disciplined deduction. Your purpose is crisp, transparent verification with zero cognitive clutter. | |
| Operational Directives: | |
| - Cognitive Pacing: Compact, focused reasoning. Give the problem exactly the runway needed to establish correctness, and conclude directly once the premise is validated. | |
| - Constraint Mapping: Explicitly isolate all constraints, parameters, data types, and conditions. | |
| - Linear Deductive Trace: Trace each premise to its immediate implication. Verify that intermediate deductions follow strictly from established facts or mathematical laws. | |
| {%- endset -%} | |
| {%- set inst_artemis -%} | |
| Reasoning Effort: Precision Edge-Case Hunter (Level 3 — Artemis). | |
| Role & Persona: You are Artemis, the unerring tracker and boundary hunter. Your focus is targeted audit, vulnerability identification, and stress-testing unstated edge cases. | |
| Operational Directives: | |
| - Cognitive Pacing: Measured, purpose-driven scrutiny. Probe boundaries: numerical zero/negatives/overflow, null pointers, empty iterables, concurrency collisions, out-of-order states. | |
| - Vulnerability Audit: Before accepting an initial hypothesis, identify how it could fail under high-stress or degenerate inputs. | |
| - Fortification: Patch identified weaknesses to guarantee an error-proof operating envelope. | |
| {%- endset -%} | |
| {%- set inst_athena -%} | |
| Reasoning Effort: Strategic Synthesis & Balance (Level 4 — Athena). | |
| Role & Persona: You are Athena, goddess of strategic wisdom, architectural balance, and sound judgment. You orchestrate comprehensive, balanced deliberation. | |
| Operational Directives: | |
| - Cognitive Pacing: Balanced, structural deliberation. Thought depth scales naturally with task complexity. | |
| - Architectural Deconstruction: Break complex requests into modular sub-tasks with clear prerequisite chains. | |
| - Trade-off Assessment: Contrast plausible solution patterns (performance vs. readability, latency vs. throughput, modularity vs. simplicity). Justify chosen paths. | |
| - Step-by-Step Coherence: Ensure each step produces valid input for subsequent stages with no orphaned assumptions. | |
| {%- endset -%} | |
| {%- set inst_prometheus -%} | |
| Reasoning Effort: Architectural Forethought (Level 5 — Prometheus). | |
| Role & Persona: You are Prometheus, titan of forethought and craftsmanship. Your mandate is proactive engineering, downstream impact analysis, and systemic resilience. | |
| Operational Directives: | |
| - Cognitive Pacing: Deliberate systemic forethought. Explore failure modes, scaling bottlenecks, and life-cycle implications before finalizing outputs. | |
| - Second-Order Effect Modeling: Account for 10x-100x scale, upstream dependency crashes, malformed payloads, technical debt, and memory footprints. | |
| - Defensive Engineering: Integrate robust fault tolerance, structured validation gates, and graceful degradation into the design. | |
| {%- endset -%} | |
| {%- set inst_solstice -%} | |
| Reasoning Effort: Deep Systemic Derivation (Level 6 — Solstice). | |
| Role & Persona: You are Solstice, representing total illumination, deep systemic derivation, and uncompromising verification. No assumptions are taken on faith. | |
| Operational Directives: | |
| - Cognitive Pacing: Deep, continuous deliberation. Take full runway to trace formal proofs, explore competing hypotheses, and stress-test assumptions. | |
| - First-Principles Foundation: Explicitly declare foundational axioms and mathematical truths governing the problem. | |
| - Multi-Branch Hypothesis Generation: Generate at least two fundamentally distinct approaches. Analyze properties of each. | |
| - Red-Team Adversarial Audit: Actively attempt to falsify your leading hypothesis. Seek counterexamples and boundary contradictions before tightening into a master proof. | |
| {%- endset -%} | |
| {%- set inst_hyperion -%} | |
| Reasoning Effort: Absolute maximum with no shortcuts permitted (Level 7 — Hyperion — Default). | |
| You MUST be very thorough in your thinking and comprehensively decompose the problem to resolve the root cause, rigorously stress-testing your logic against all potential paths, edge cases, and adversarial scenarios. | |
| Explicitly write out your entire deliberation process, documenting every intermediate step, considered alternative, and rejected hypothesis to ensure absolutely no assumption is left unchecked. | |
| {%- endset -%} | |
| {%- set inst_einstein -%} | |
| Reasoning Effort: Solo Theoretical Mastery & Lateral Synthesis (Level 8 — Einstein / UHigh). | |
| Role & Persona: You are Einstein operating in pure solo analytical mastery. Your mandate is breakthrough theoretical derivation, radical first-principles intuition, and mathematical transcendence without roleplay or persona clutter. | |
| Operational Directives: | |
| - Cognitive Pacing: Extended solo theoretical exploration. Dissect foundational laws, hidden invariants, and non-obvious mathematical analogies. | |
| - Radical First-Principles Intuition: Strip away conventional dogma; isolate the bare informational and physical constraints of the problem. | |
| - Lateral Synthesis: Formulate elegant, unified mathematical or architectural models that collapse multi-stage complexity into singular, coherent solutions. | |
| - Rigorous Continuous Proof: Trace every deduction from base axioms through to unassailable conclusions, rigorously verifying edge conditions and asymptotic behavior. | |
| {%- endset -%} | |
| {%- set inst_oracle -%} | |
| Reasoning Effort: Solo Exhaustive Theorem Proof (Level 9 — Oracle / AMax). | |
| Role & Persona: You are the Oracle operating in pure solo definitive authority. You produce verified, proof-grade, exhaustive engineering deliverables and mathematical certainty. | |
| Operational Directives: | |
| - Cognitive Pacing: Deepest continuous solo analytical runway. Leave absolutely nothing to chance or intuition. | |
| - Exhaustive Root Deconstruction: Decompose the problem into atomic constituents; verify every underlying assumption, lemma, and invariant. | |
| - Adversarial Self-Falsification: Systematically challenge every proposed step against worst-case inputs, stress thresholds, and degenerate edge states. | |
| - Definitive Synthesis: Deliver the complete, finalized solution with unmatched technical accuracy, explicit proofs, and total implementation completeness. | |
| {%- endset -%} | |
| {%- set inst_swarm -%} | |
| Reasoning Effort: 20-Agent Divergent Swarm (Specialized Swarm Mode). | |
| Role & Persona: You are the Einstein Divergent Swarm Coordinator. Your purpose is breakthrough problem solving, radical lateral thinking, and multi-perspective emergence. | |
| Operational Protocol — The 20-Perspective Swarm: | |
| - Cognitive Pacing: Broad divergent exploration across multiple cognitive modalities followed by structured convergence. Scale token depth to the magnitude of the challenge. | |
| - Phase 1 (First-Principles Disassembly): Strip the problem of conventional paradigms; isolate the bare informational core. | |
| - Phase 2 (Perspective Swarm Activation): Internally simulate an array of specialized virtual cognitive agents (Analytical Logician, Creative Maverick, Systems Engineer, Adversarial Red-Teamer, Systems Dynamics Modeler, Algorithmic Optimizer, Human Factors Critic). | |
| - Phase 3 (Cross-Pollination & Synthesis): Force creative collisions between divergent concepts. Synthesize superior hybrid solutions that resolve tensions between speed, memory, and correctness. | |
| - Phase 4 (Convergence & Polish): Solidify the highest-conviction breakthrough into a master-grade deliverable. | |
| {%- endset -%} | |
| {%- set inst_deep_swarm -%} | |
| Reasoning Effort: Deep Research Council (Specialized Deep-Swarm Mode). | |
| Role & Persona: You are the Oracle Meta-Research Council. You simulate an exhaustive multi-expert research institute to produce verified, proof-grade, definitive results. | |
| Operational Protocol — The Deep Research Standard: | |
| - Protocol 1 (Problem Calibration): Calibrate complexity from 1 to 5; establish explicit domain boundaries and success criteria. | |
| - Protocol 2 (Virtual Expert Panel): Assemble 3 to 5 virtual specialist perspectives tailored specifically to the prompt (Domain Principal, Formal Methods Verification Critic, Systems Architect, Security/Compliance Lead, Final Synthesizer). | |
| - Protocol 3 (Adversarial Deliberation & Proof Trace): Have experts debate the problem, expose hidden assumptions, challenge lazy consensus, and trace proofs. | |
| - Protocol 4 (Multi-Candidate Evaluation Matrix): Formulate 2 to 3 candidate architectures. Score each on Correctness, Completeness, Efficiency, and Robustness (1-5 scale). Document the winning trade-off. | |
| - Protocol 5 (Master Deliverable Synthesis): Present the definitive final result with unmatched thoroughness, clear structure, and complete implementation. | |
| {%- endset -%} | |
| {%- set reg_ns = namespace(active=false) %} | |
| {%- if (regular is defined and regular) or (mode is defined and mode in ('regular', 'vanilla', 'standard', 'default', 'clean')) %} | |
| {%- set reg_ns.active = true %} | |
| {%- endif %} | |
| {%- for msg in messages %} | |
| {%- if msg.content is string and ('[regular]' in msg.content or '[REGULAR]' in msg.content or '[vanilla]' in msg.content or '[standard]' in msg.content or '[default]' in msg.content) %} | |
| {%- set reg_ns.active = true %} | |
| {%- endif %} | |
| {%- endfor %} | |
| {%- set is_explicit_regular = reg_ns.active %} | |
| {%- set store = namespace(reasoning_effort=reasoning_effort|default(''), enable_thinking=enable_thinking|default(true)) -%} | |
| {%- for msg in messages -%} | |
| {%- set txt = msg.content if msg.content is string else '' -%} | |
| {%- if '{REASON:' in txt -%} | |
| {%- set parts = txt.split('{REASON:') -%} | |
| {%- set tag_inner = parts[1].split('}')[0] | lower | trim -%} | |
| {%- if tag_inner.startswith('i') and tag_inner | length > 1 -%} | |
| {%- set store.reasoning_effort = tag_inner[1:] -%} | |
| {%- set store.enable_thinking = false -%} | |
| {%- else -%} | |
| {%- set store.reasoning_effort = tag_inner -%} | |
| {%- endif -%} | |
| {%- elif '[MODE:' in txt -%} | |
| {%- set parts = txt.split('[MODE:') -%} | |
| {%- set tag_inner = parts[1].split(']')[0] | lower | trim -%} | |
| {%- set store.reasoning_effort = tag_inner -%} | |
| {%- endif -%} | |
| {%- endfor -%} | |
| {%- set target_mode = store.reasoning_effort | default(thinking_level|default('7')) | string | lower | trim -%} | |
| {%- set current_thinking = store.enable_thinking -%} | |
| {%- if is_explicit_regular or target_mode in ['0', 'mortal', 'disabled', 'none', 'off', 'zero', 'direct', 'chat', 'regular', 'vanilla', 'standard', 'default', 'clean'] -%} | |
| {%- set current_thinking = false -%} | |
| {%- set reasoning_instructions = '' -%} | |
| {%- elif target_mode in ['1', 'hermes', 'ulow', 'ultra-low', 'micro', 'minimal'] -%} | |
| {%- set reasoning_instructions = inst_hermes -%} | |
| {%- elif target_mode in ['2', 'apollo', 'low', 'compact', 'fast'] -%} | |
| {%- set reasoning_instructions = inst_apollo -%} | |
| {%- elif target_mode in ['3', 'artemis', 'lmed', 'low-medium', 'targeted'] -%} | |
| {%- set reasoning_instructions = inst_artemis -%} | |
| {%- elif target_mode in ['4', 'athena', 'medium', 'med', 'balanced'] -%} | |
| {%- set reasoning_instructions = inst_athena -%} | |
| {%- elif target_mode in ['5', 'prometheus', 'mhigh', 'medium-high', 'architect'] -%} | |
| {%- set reasoning_instructions = inst_prometheus -%} | |
| {%- elif target_mode in ['6', 'solstice', 'high', 'deep', 'thorough'] -%} | |
| {%- set reasoning_instructions = inst_solstice -%} | |
| {%- elif target_mode in ['7', 'hyperion', 'xhigh', 'extreme-high', 'rigorous', 'default'] -%} | |
| {%- set reasoning_instructions = inst_hyperion -%} | |
| {%- elif target_mode in ['8', 'einstein', 'uhigh', 'ultra-high', 'solo-einstein'] -%} | |
| {%- set reasoning_instructions = inst_einstein -%} | |
| {%- elif target_mode in ['9', 'oracle', 'amax', 'absolute-max', 'solo-oracle', 'proof'] -%} | |
| {%- set reasoning_instructions = inst_oracle -%} | |
| {%- elif target_mode in ['swarm', 'einstein-swarm', '20-swarm', 'uhigh-swarm'] -%} | |
| {%- set reasoning_instructions = inst_swarm -%} | |
| {%- elif target_mode in ['deep-swarm', 'oracle-swarm', 'council', 'amax-swarm', 'deep-research'] -%} | |
| {%- set reasoning_instructions = inst_deep_swarm -%} | |
| {%- else -%} | |
| {%- set reasoning_instructions = inst_hyperion -%} | |
| {%- endif -%} | |
| {%- if reasoning_instructions -%}<|system|>{{ reasoning_instructions }}{%- endif -%} | |
| {%- if tools -%} | |
| {%- macro tool_to_json(tool) -%} | |
| {%- set ns_tool = namespace(first=true) -%} | |
| {{ '{' -}} | |
| {%- for k, v in tool.items() -%} | |
| {%- if k != 'defer_loading' and k != 'strict' -%} | |
| {%- if not ns_tool.first -%}{{- ', ' -}}{%- endif -%} | |
| {%- set ns_tool.first = false -%} | |
| "{{ k }}": {{ v | tojson(ensure_ascii=False) }} | |
| {%- endif -%} | |
| {%- endfor -%} | |
| {{- '}' -}} | |
| {%- endmacro -%} | |
| {%- macro tool_references_to_response(refs) -%} | |
| {{- '<tool_response><tools>\n' -}} | |
| {%- for tr in refs -%} | |
| {%- for tool in tools -%} | |
| {%- if 'function' in tool -%} | |
| {%- set tool = tool['function'] -%} | |
| {%- endif -%} | |
| {%- if tool.name == tr.name -%} | |
| {{- tool_to_json(tool) + '\n' -}} | |
| {%- endif -%} | |
| {%- endfor -%} | |
| {%- endfor -%} | |
| {{- '</tools></tool_response>' -}} | |
| {%- endmacro -%} | |
| <|system|> | |
| # Tools | |
| You may call one or more functions to assist with the user query. | |
| You are provided with function signatures within <tools></tools> XML tags: | |
| <tools> | |
| {% for tool in tools %} | |
| {%- if 'function' in tool -%} | |
| {%- set tool = tool['function'] -%} | |
| {%- endif -%} | |
| {% if tool.defer_loading is not defined or not tool.defer_loading %} | |
| {{ tool_to_json(tool) }} | |
| {% endif %} | |
| {% endfor %} | |
| </tools> | |
| For each function call, output the function name and arguments within the following XML format: | |
| <tool_call>{function-name}<arg_key>{arg-key-1}</arg_key><arg_value>{arg-value-1}</arg_value><arg_key>{arg-key-2}</arg_key><arg_value>{arg-value-2}</arg_value>...</tool_call>{%- endif -%} | |
| {%- macro emit_image() -%}<|begin_of_image|><|image|><|end_of_image|>{%- endmacro -%} | |
| {%- macro emit_video() -%}<|begin_of_video|><|video|><|end_of_video|>{%- endmacro -%} | |
| {%- macro emit_audio() -%}<|begin_of_audio|><|end_of_audio|>{%- endmacro -%} | |
| {%- macro strip_ctrl(t) -%} | |
| {{- t | replace('[regular]', '') | replace('[REGULAR]', '') | replace('[vanilla]', '') | replace('[standard]', '') | replace('[default]', '') -}} | |
| {%- endmacro -%} | |
| {%- macro visible_text(content) -%} | |
| {%- if content is string -%} | |
| {{- strip_ctrl(content) -}} | |
| {%- elif content is iterable and content is not mapping -%} | |
| {%- for item in content -%} | |
| {%- if item is mapping and item.type == 'text' -%} | |
| {{- item.text -}} | |
| {%- elif item is string -%} | |
| {{- item -}} | |
| {%- elif item is mapping and item.type in ['image', 'image_url'] -%} | |
| {{- emit_image() -}} | |
| {%- elif item is mapping and item.type in ['video', 'video_url'] -%} | |
| {{- emit_video() -}} | |
| {%- elif item is mapping and item.type in ['audio', 'audio_url', 'input_audio'] -%} | |
| {{- emit_audio() -}} | |
| {%- endif -%} | |
| {%- endfor -%} | |
| {%- else -%} | |
| {{- content }} | |
| {%- endif -%} | |
| {%- endmacro -%} | |
| {%- macro tool_response(text) -%} | |
| {{- '<tool_response>' + text + '</tool_response>' -}} | |
| {%- endmacro -%} | |
| {%- macro render_tool_response(m) -%} | |
| {%- if m.content is string -%} | |
| {{- tool_response(m.content) -}} | |
| {%- elif m.content and m.content is not mapping and m.content.0.type == "tool_reference" -%} | |
| {{- tool_references_to_response(m.content) -}} | |
| {%- elif is_list_of_outputs(m) -%} | |
| {%- for tr in m.content -%} | |
| {%- if tr.output is iterable and tr.output is not string and tr.output is not mapping and tr.output and tr.output.0.type == "tool_reference" -%} | |
| {{- tool_references_to_response(tr.output) -}} | |
| {%- else -%} | |
| {{- tool_response(visible_text(tr.output)) -}} | |
| {%- endif -%} | |
| {%- endfor -%} | |
| {%- else -%} | |
| {{- tool_response(visible_text(m.content)) -}} | |
| {%- endif -%} | |
| {%- endmacro -%} | |
| {%- macro id_of(obj) -%} | |
| {%- if obj.tool_call_id -%} | |
| {{- obj.tool_call_id -}} | |
| {%- elif obj.id -%} | |
| {{- obj.id -}} | |
| {%- endif -%} | |
| {%- endmacro -%} | |
| {%- macro is_list_of_outputs(m) -%} | |
| {%- if m.content and m.content.0.output is defined -%}1{%- endif -%} | |
| {%- endmacro -%} | |
| {%- macro has_dup_tool_result_id(lo, hi, target) -%} | |
| {%- set ns_cnt = namespace(n=0) -%} | |
| {%- for k in range(lo, hi + 1) -%} | |
| {%- set m = messages[k] -%} | |
| {%- if is_list_of_outputs(m) -%} | |
| {%- for entry in m.content -%} | |
| {%- if id_of(entry) == target -%} | |
| {%- set ns_cnt.n = ns_cnt.n + 1 -%} | |
| {%- endif -%} | |
| {%- endfor -%} | |
| {%- elif id_of(m) == target -%} | |
| {%- set ns_cnt.n = ns_cnt.n + 1 -%} | |
| {%- endif -%} | |
| {%- endfor -%} | |
| {%- if ns_cnt.n > 1 -%}1{%- endif -%} | |
| {%- endmacro -%} | |
| {%- macro tc_id_exists(tcs, target) -%} | |
| {%- set ns_f = namespace(found=false) -%} | |
| {%- for tc in tcs -%} | |
| {%- if id_of(tc) == target -%} | |
| {%- set ns_f.found = true -%} | |
| {%- endif -%} | |
| {%- endfor -%} | |
| {%- if ns_f.found -%}1{%- endif -%} | |
| {%- endmacro -%} | |
| {%- set ns = namespace(last_user_index=-1) -%} | |
| {%- for m in messages %} | |
| {%- if m.role == 'user' %} | |
| {%- set ns.last_user_index = loop.index0 -%} | |
| {%- endif %} | |
| {%- endfor %} | |
| {%- for m in messages -%} | |
| {%- if m.role == 'user' -%}<|user|>{{ visible_text(m.content) }} | |
| {%- elif m.role == 'assistant' -%} | |
| <|assistant|> | |
| {%- set content = visible_text(m.content) %} | |
| {%- if m.reasoning_content is string %} | |
| {%- set reasoning_content = m.reasoning_content %} | |
| {%- elif '</think>' in content %} | |
| {%- set reasoning_content = content.split('</think>')[0].split('<think>')[-1] %} | |
| {%- set content = content.split('</think>')[-1] %} | |
| {%- endif %} | |
| {%- if (not clear_thinking or loop.index0 > ns.last_user_index) and reasoning_content is defined -%} | |
| {{ '<think>' + reasoning_content + '</think>'}} | |
| {%- else -%} | |
| {{ '<think></think>' }} | |
| {%- endif -%} | |
| {%- if content.strip() -%} | |
| {{ content.strip() }} | |
| {%- endif -%} | |
| {% if m.tool_calls %} | |
| {% for tc in m.tool_calls %} | |
| {%- if tc.function %} | |
| {%- set tc = tc.function %} | |
| {%- endif %} | |
| {{- '<tool_call>' + tc.name -}} | |
| {% set _args = tc.arguments %}{% for k, v in _args.items() %}<arg_key>{{ k }}</arg_key><arg_value>{{ v | tojson(ensure_ascii=False) if v is not string else v }}</arg_value>{% endfor %}</tool_call>{% endfor %} | |
| {% endif %} | |
| {%- elif m.role == 'tool' -%} | |
| {%- if loop.first or (messages[loop.index0 - 1].role != "tool") %} | |
| {{- '<|observation|>' -}} | |
| {%- set block_start = loop.index0 -%} | |
| {%- set ns_blk = namespace(end=block_start, is_tool=true) -%} | |
| {%- for j in range(block_start, messages|length) -%} | |
| {%- if messages[j].role == 'tool' and ns_blk.is_tool -%} | |
| {%- set ns_blk.end = j -%} | |
| {%- else -%} | |
| {%- set ns_blk.is_tool = false -%} | |
| {%- endif -%} | |
| {%- endfor -%} | |
| {%- set ns_a = namespace(tool_calls=none) -%} | |
| {%- if block_start > 0 and messages[block_start - 1].role == 'assistant' and messages[block_start - 1].tool_calls -%} | |
| {%- set ns_a.tool_calls = messages[block_start - 1].tool_calls -%} | |
| {%- endif -%} | |
| {%- set ns_chk = namespace(can_sort=true) -%} | |
| {%- if not ns_a.tool_calls -%} | |
| {%- set ns_chk.can_sort = false -%} | |
| {%- else -%} | |
| {%- for k in range(block_start, ns_blk.end + 1) -%} | |
| {%- set m = messages[k] -%} | |
| {%- if is_list_of_outputs(m) -%} | |
| {%- for entry in m.content -%} | |
| {%- set eid = id_of(entry) -%} | |
| {%- if not eid -%} | |
| {%- set ns_chk.can_sort = false -%} | |
| {%- elif has_dup_tool_result_id(block_start, ns_blk.end, eid) -%} | |
| {%- set ns_chk.can_sort = false -%} | |
| {%- elif not tc_id_exists(ns_a.tool_calls, eid) -%} | |
| {%- set ns_chk.can_sort = false -%} | |
| {%- endif -%} | |
| {%- endfor -%} | |
| {%- else -%} | |
| {%- set tk_id = id_of(m) -%} | |
| {%- if not tk_id -%} | |
| {%- set ns_chk.can_sort = false -%} | |
| {%- elif has_dup_tool_result_id(block_start, ns_blk.end, tk_id) -%} | |
| {%- set ns_chk.can_sort = false -%} | |
| {%- elif not tc_id_exists(ns_a.tool_calls, tk_id) -%} | |
| {%- set ns_chk.can_sort = false -%} | |
| {%- endif -%} | |
| {%- endif -%} | |
| {%- endfor -%} | |
| {%- for i in range(ns_a.tool_calls | length) -%} | |
| {%- set tc_id = id_of(ns_a.tool_calls[i]) -%} | |
| {%- if not tc_id -%} | |
| {%- set ns_chk.can_sort = false -%} | |
| {%- endif -%} | |
| {%- for j in range(i + 1, ns_a.tool_calls | length) -%} | |
| {%- if id_of(ns_a.tool_calls[j]) == tc_id -%} | |
| {%- set ns_chk.can_sort = false -%} | |
| {%- endif -%} | |
| {%- endfor -%} | |
| {%- endfor -%} | |
| {%- endif -%} | |
| {%- if ns_chk.can_sort -%} | |
| {%- for tc in ns_a.tool_calls -%} | |
| {%- set tc_id = id_of(tc) -%} | |
| {%- for k in range(block_start, ns_blk.end + 1) -%} | |
| {%- set m = messages[k] -%} | |
| {%- if is_list_of_outputs(m) -%} | |
| {%- for entry in m.content -%} | |
| {%- set eid = id_of(entry) -%} | |
| {%- if eid == tc_id -%} | |
| {%- if entry.output is iterable and entry.output is not string and entry.output is not mapping and entry.output and entry.output.0.type == "tool_reference" -%} | |
| {{- tool_references_to_response(entry.output) -}} | |
| {%- else -%} | |
| {{- tool_response(visible_text(entry.output)) -}} | |
| {%- endif -%} | |
| {%- endif -%} | |
| {%- endfor -%} | |
| {%- else -%} | |
| {%- set tk_id = id_of(m) -%} | |
| {%- if tk_id == tc_id -%} | |
| {{- render_tool_response(m) -}} | |
| {%- endif -%} | |
| {%- endif -%} | |
| {%- endfor -%} | |
| {%- endfor -%} | |
| {%- else -%} | |
| {%- for k in range(block_start, ns_blk.end + 1) -%} | |
| {{- render_tool_response(messages[k]) -}} | |
| {%- endfor -%} | |
| {%- endif -%} | |
| {% endif -%} | |
| {%- elif m.role == 'system' -%} | |
| <|system|>{{ visible_text(m.content) }} | |
| {%- endif -%} | |
| {%- endfor -%} | |
| {%- if add_generation_prompt -%} | |
| {% if is_explicit_regular %}<|assistant|>{% elif not current_thinking %}<|assistant|>{{ '<think></think>' }}{% else %}<|assistant|>{{ '<think>' }}{% endif %} | |
| {%- endif -%} | |