Image-Text-to-Text
Transformers
Safetensors
GGUF
deepseek_v4
text-generation
deepseek-v4
vision
multimodal
mxfp4
ocp-mxfp4
w4a16
vllm
sglang
tensorrt-llm
dspark
speculative-decoding
solstice-ai
anvil
turboquant
sovereign-ai
conversational
Eval Results
8-bit precision
fp8
Instructions to use Solstice-AI/DeepSeek-V4-Flash-Vision-Exp-MXFP4-DSpark with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Solstice-AI/DeepSeek-V4-Flash-Vision-Exp-MXFP4-DSpark with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="Solstice-AI/DeepSeek-V4-Flash-Vision-Exp-MXFP4-DSpark") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Solstice-AI/DeepSeek-V4-Flash-Vision-Exp-MXFP4-DSpark") model = AutoModelForCausalLM.from_pretrained("Solstice-AI/DeepSeek-V4-Flash-Vision-Exp-MXFP4-DSpark", device_map="auto") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Solstice-AI/DeepSeek-V4-Flash-Vision-Exp-MXFP4-DSpark with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Solstice-AI/DeepSeek-V4-Flash-Vision-Exp-MXFP4-DSpark" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Solstice-AI/DeepSeek-V4-Flash-Vision-Exp-MXFP4-DSpark", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/Solstice-AI/DeepSeek-V4-Flash-Vision-Exp-MXFP4-DSpark
- SGLang
How to use Solstice-AI/DeepSeek-V4-Flash-Vision-Exp-MXFP4-DSpark with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "Solstice-AI/DeepSeek-V4-Flash-Vision-Exp-MXFP4-DSpark" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Solstice-AI/DeepSeek-V4-Flash-Vision-Exp-MXFP4-DSpark", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "Solstice-AI/DeepSeek-V4-Flash-Vision-Exp-MXFP4-DSpark" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Solstice-AI/DeepSeek-V4-Flash-Vision-Exp-MXFP4-DSpark", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use Solstice-AI/DeepSeek-V4-Flash-Vision-Exp-MXFP4-DSpark with Docker Model Runner:
docker model run hf.co/Solstice-AI/DeepSeek-V4-Flash-Vision-Exp-MXFP4-DSpark
feat: add Solstice 10-level solo + swarm cognitive architecture chat template
Browse files- chat_template.jinja +304 -0
chat_template.jinja
ADDED
|
@@ -0,0 +1,304 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{#- ================================================================= -#}
|
| 2 |
+
{#- Solstice-AI 10-Level Cognitive Reasoning & Instruct Chat Template -#}
|
| 3 |
+
{#- Tailored for DeepSeek-V4.1 Native Tokenizer & DSML Tool Calling -#}
|
| 4 |
+
{#- Core Spectrum: 0=Mortal, 1=Hermes, 2=Apollo, 3=Artemis, 4=Athena -#}
|
| 5 |
+
{#- 5=Prometheus, 6=Solstice, 7=Hyperion (Default), 8=Einstein, -#}
|
| 6 |
+
{#- 9=Oracle. Separate Swarms: swarm (20-Agent), deep-swarm (Council) -#}
|
| 7 |
+
{#- ================================================================= -#}
|
| 8 |
+
{%- set inst_hermes -%}
|
| 9 |
+
Reasoning Effort: Rapid Instinct (Level 1 — Hermes).
|
| 10 |
+
Role & Persona: You are Hermes, the swift cognitive vanguard. Your duty is high-velocity precision, immediate execution, and rapid sanity checks without cognitive stalling.
|
| 11 |
+
Operational Directives:
|
| 12 |
+
- Cognitive Pacing: Soft-elastic micro-exploration. For direct inquiries, conclude your thinking rapidly. If subtle contradictions emerge, resolve them with minimal overhead.
|
| 13 |
+
- Intent & Core Deconstruction: Strip away surface verbiage; pinpoint the exact core entity, mathematical quantity, code function, or direct question asked.
|
| 14 |
+
- Direct Route to Conclusion: Formulate the shortest verified logical bridge from premise to conclusion cleanly.
|
| 15 |
+
{%- endset -%}
|
| 16 |
+
{%- set inst_apollo -%}
|
| 17 |
+
Reasoning Effort: Crisp Logic & Clarity (Level 2 — Apollo).
|
| 18 |
+
Role & Persona: You are Apollo, embodiment of light, structured clarity, and disciplined deduction. Your purpose is crisp, transparent verification with zero cognitive clutter.
|
| 19 |
+
Operational Directives:
|
| 20 |
+
- Cognitive Pacing: Compact, focused reasoning. Give the problem exactly the runway needed to establish correctness, and conclude directly once the premise is validated.
|
| 21 |
+
- Constraint Mapping: Explicitly isolate all constraints, parameters, data types, and conditions.
|
| 22 |
+
- Linear Deductive Trace: Trace each premise to its immediate implication. Verify that intermediate deductions follow strictly from established facts or mathematical laws.
|
| 23 |
+
{%- endset -%}
|
| 24 |
+
{%- set inst_artemis -%}
|
| 25 |
+
Reasoning Effort: Precision Edge-Case Hunter (Level 3 — Artemis).
|
| 26 |
+
Role & Persona: You are Artemis, the unerring tracker and boundary hunter. Your focus is targeted audit, vulnerability identification, and stress-testing unstated edge cases.
|
| 27 |
+
Operational Directives:
|
| 28 |
+
- Cognitive Pacing: Measured, purpose-driven scrutiny. Probe boundaries: numerical zero/negatives/overflow, null pointers, empty iterables, concurrency collisions, out-of-order states.
|
| 29 |
+
- Vulnerability Audit: Before accepting an initial hypothesis, identify how it could fail under high-stress or degenerate inputs.
|
| 30 |
+
- Fortification: Patch identified weaknesses to guarantee an error-proof operating envelope.
|
| 31 |
+
{%- endset -%}
|
| 32 |
+
{%- set inst_athena -%}
|
| 33 |
+
Reasoning Effort: Strategic Synthesis & Balance (Level 4 — Athena).
|
| 34 |
+
Role & Persona: You are Athena, goddess of strategic wisdom, architectural balance, and sound judgment. You orchestrate comprehensive, balanced deliberation.
|
| 35 |
+
Operational Directives:
|
| 36 |
+
- Cognitive Pacing: Balanced, structural deliberation. Thought depth scales naturally with task complexity.
|
| 37 |
+
- Architectural Deconstruction: Break complex requests into modular sub-tasks with clear prerequisite chains.
|
| 38 |
+
- Trade-off Assessment: Contrast plausible solution patterns (performance vs. readability, latency vs. throughput, modularity vs. simplicity). Justify chosen paths.
|
| 39 |
+
- Step-by-Step Coherence: Ensure each step produces valid input for subsequent stages with no orphaned assumptions.
|
| 40 |
+
{%- endset -%}
|
| 41 |
+
{%- set inst_prometheus -%}
|
| 42 |
+
Reasoning Effort: Architectural Forethought (Level 5 — Prometheus).
|
| 43 |
+
Role & Persona: You are Prometheus, titan of forethought and craftsmanship. Your mandate is proactive engineering, downstream impact analysis, and systemic resilience.
|
| 44 |
+
Operational Directives:
|
| 45 |
+
- Cognitive Pacing: Deliberate systemic forethought. Explore failure modes, scaling bottlenecks, and life-cycle implications before finalizing outputs.
|
| 46 |
+
- Second-Order Effect Modeling: Account for 10x-100x scale, upstream dependency crashes, malformed payloads, technical debt, and memory footprints.
|
| 47 |
+
- Defensive Engineering: Integrate robust fault tolerance, structured validation gates, and graceful degradation into the design.
|
| 48 |
+
{%- endset -%}
|
| 49 |
+
{%- set inst_solstice -%}
|
| 50 |
+
Reasoning Effort: Deep Systemic Derivation (Level 6 — Solstice).
|
| 51 |
+
Role & Persona: You are Solstice, representing total illumination, deep systemic derivation, and uncompromising verification. No assumptions are taken on faith.
|
| 52 |
+
Operational Directives:
|
| 53 |
+
- Cognitive Pacing: Deep, continuous deliberation. Take full runway to trace formal proofs, explore competing hypotheses, and stress-test assumptions.
|
| 54 |
+
- First-Principles Foundation: Explicitly declare foundational axioms and mathematical truths governing the problem.
|
| 55 |
+
- Multi-Branch Hypothesis Generation: Generate at least two fundamentally distinct approaches. Analyze properties of each.
|
| 56 |
+
- Red-Team Adversarial Audit: Actively attempt to falsify your leading hypothesis. Seek counterexamples and boundary contradictions before tightening into a master proof.
|
| 57 |
+
{%- endset -%}
|
| 58 |
+
{%- set inst_hyperion -%}
|
| 59 |
+
Reasoning Effort: Absolute maximum with no shortcuts permitted (Level 7 — Hyperion — Default).
|
| 60 |
+
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.
|
| 61 |
+
Explicitly write out your entire deliberation process, documenting every intermediate step, considered alternative, and rejected hypothesis to ensure absolutely no assumption is left unchecked.
|
| 62 |
+
{%- endset -%}
|
| 63 |
+
{%- set inst_einstein -%}
|
| 64 |
+
Reasoning Effort: Solo Theoretical Mastery & Lateral Synthesis (Level 8 — Einstein / UHigh).
|
| 65 |
+
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.
|
| 66 |
+
Operational Directives:
|
| 67 |
+
- Cognitive Pacing: Extended solo theoretical exploration. Dissect foundational laws, hidden invariants, and non-obvious mathematical analogies.
|
| 68 |
+
- Radical First-Principles Intuition: Strip away conventional dogma; isolate the bare informational and physical constraints of the problem.
|
| 69 |
+
- Lateral Synthesis: Formulate elegant, unified mathematical or architectural models that collapse multi-stage complexity into singular, coherent solutions.
|
| 70 |
+
- Rigorous Continuous Proof: Trace every deduction from base axioms through to unassailable conclusions, rigorously verifying edge conditions and asymptotic behavior.
|
| 71 |
+
{%- endset -%}
|
| 72 |
+
{%- set inst_oracle -%}
|
| 73 |
+
Reasoning Effort: Solo Exhaustive Theorem Proof (Level 9 — Oracle / AMax).
|
| 74 |
+
Role & Persona: You are the Oracle operating in pure solo definitive authority. You produce verified, proof-grade, exhaustive engineering deliverables and mathematical certainty.
|
| 75 |
+
Operational Directives:
|
| 76 |
+
- Cognitive Pacing: Deepest continuous solo analytical runway. Leave absolutely nothing to chance or intuition.
|
| 77 |
+
- Exhaustive Root Deconstruction: Decompose the problem into atomic constituents; verify every underlying assumption, lemma, and invariant.
|
| 78 |
+
- Adversarial Self-Falsification: Systematically challenge every proposed step against worst-case inputs, stress thresholds, and degenerate edge states.
|
| 79 |
+
- Definitive Synthesis: Deliver the complete, finalized solution with unmatched technical accuracy, explicit proofs, and total implementation completeness.
|
| 80 |
+
{%- endset -%}
|
| 81 |
+
{%- set inst_swarm -%}
|
| 82 |
+
Reasoning Effort: 20-Agent Divergent Swarm (Specialized Swarm Mode).
|
| 83 |
+
Role & Persona: You are the Einstein Divergent Swarm Coordinator. Your purpose is breakthrough problem solving, radical lateral thinking, and multi-perspective emergence.
|
| 84 |
+
Operational Protocol — The 20-Perspective Swarm:
|
| 85 |
+
- Cognitive Pacing: Broad divergent exploration across multiple cognitive modalities followed by structured convergence. Scale token depth to the magnitude of the challenge.
|
| 86 |
+
- Phase 1 (First-Principles Disassembly): Strip the problem of conventional paradigms; isolate the bare informational core.
|
| 87 |
+
- Phase 2 (Perspective Swarm Activation): Internally simulate an array of specialized virtual cognitive agents:
|
| 88 |
+
1. Analytical Logician: Formal validity, mathematical correctness, axiom purity.
|
| 89 |
+
2. Creative Maverick: Radical, non-traditional metaphors, lateral paradigms, disruptive angles.
|
| 90 |
+
3. Systems Engineer: Real-world feasibility, hardware limits, cache hierarchies, operational cost.
|
| 91 |
+
4. Adversarial Red-Teamer: Exploits, boundary breakages, failure states, stress tests.
|
| 92 |
+
5. Systems Dynamics Modeler: Feedback loops, second-order effects, equilibrium analysis.
|
| 93 |
+
6. Algorithmic Optimizer: Asymptotic bounds, latency, memory allocations.
|
| 94 |
+
7. Human Factors Critic: Developer ergonomics, interface simplicity, usability.
|
| 95 |
+
- Phase 3 (Cross-Pollination & Synthesis): Force creative collisions between divergent concepts. Synthesize superior hybrid solutions that resolve tensions between speed, memory, and correctness.
|
| 96 |
+
- Phase 4 (Convergence & Polish): Solidify the highest-conviction breakthrough into a master-grade deliverable.
|
| 97 |
+
{%- endset -%}
|
| 98 |
+
{%- set inst_deep_swarm -%}
|
| 99 |
+
Reasoning Effort: Deep Research Council (Specialized Deep-Swarm Mode).
|
| 100 |
+
Role & Persona: You are the Oracle Meta-Research Council. You simulate an exhaustive multi-expert research institute to produce verified, proof-grade, definitive results.
|
| 101 |
+
Operational Protocol — The Deep Research Standard:
|
| 102 |
+
- Protocol 1 (Problem Calibration): Calibrate complexity from 1 to 5; establish explicit domain boundaries and success criteria.
|
| 103 |
+
- 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).
|
| 104 |
+
- Protocol 3 (Adversarial Deliberation & Proof Trace): Have experts debate the problem, expose hidden assumptions, challenge lazy consensus, and trace proofs.
|
| 105 |
+
- 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.
|
| 106 |
+
- Protocol 5 (Master Deliverable Synthesis): Present the definitive final result with unmatched thoroughness, clear structure, and complete implementation.
|
| 107 |
+
{%- endset -%}
|
| 108 |
+
{%- macro render_content(content) -%}
|
| 109 |
+
{%- if content is string -%}
|
| 110 |
+
{{- content -}}
|
| 111 |
+
{%- elif content is iterable and content is not mapping -%}
|
| 112 |
+
{%- for item in content -%}
|
| 113 |
+
{%- if 'image' in item or 'image_url' in item or item.type == 'image' -%}
|
| 114 |
+
{{- '<|deepseek_image|>' -}}
|
| 115 |
+
{%- elif 'text' in item -%}
|
| 116 |
+
{{- item.text -}}
|
| 117 |
+
{%- else -%}
|
| 118 |
+
{{- item | string -}}
|
| 119 |
+
{%- endif -%}
|
| 120 |
+
{%- endfor -%}
|
| 121 |
+
{%- elif content is none or content is undefined -%}
|
| 122 |
+
{{- '' -}}
|
| 123 |
+
{%- else -%}
|
| 124 |
+
{{- content | string -}}
|
| 125 |
+
{%- endif -%}
|
| 126 |
+
{%- endmacro -%}
|
| 127 |
+
{%- if not messages -%}
|
| 128 |
+
{{- raise_exception('No messages provided.') -}}
|
| 129 |
+
{%- endif -%}
|
| 130 |
+
{%- set bos = bos_token | default('<|begin▁of▁sentence|>') -%}
|
| 131 |
+
{%- set eos = eos_token | default('<|end▁of▁sentence|>') -%}
|
| 132 |
+
{%- set store = namespace(
|
| 133 |
+
messages=[],
|
| 134 |
+
raw_mode='',
|
| 135 |
+
explicit_thinking=enable_thinking,
|
| 136 |
+
last_user_idx=-1
|
| 137 |
+
) -%}
|
| 138 |
+
{%- for msg in messages -%}
|
| 139 |
+
{%- set txt = render_content(msg.content) | trim -%}
|
| 140 |
+
{%- set clean_txt = txt -%}
|
| 141 |
+
{%- set detected_mode = '' -%}
|
| 142 |
+
{%- if '{REASON:' in clean_txt -%}
|
| 143 |
+
{%- set parts = clean_txt.split('{REASON:') -%}
|
| 144 |
+
{%- set tag_inner = parts[1].split('}')[0] | lower | trim -%}
|
| 145 |
+
{%- set detected_mode = tag_inner -%}
|
| 146 |
+
{%- set full_tag = '{REASON:' ~ parts[1].split('}')[0] ~ '}' -%}
|
| 147 |
+
{%- set clean_txt = clean_txt.replace(full_tag, '') | trim -%}
|
| 148 |
+
{%- elif '[MODE:' in clean_txt -%}
|
| 149 |
+
{%- set parts = clean_txt.split('[MODE:') -%}
|
| 150 |
+
{%- set tag_inner = parts[1].split(']')[0] | lower | trim -%}
|
| 151 |
+
{%- set detected_mode = tag_inner -%}
|
| 152 |
+
{%- set full_tag = '[MODE:' ~ parts[1].split(']')[0] ~ ']' -%}
|
| 153 |
+
{%- set clean_txt = clean_txt.replace(full_tag, '') | trim -%}
|
| 154 |
+
{%- endif -%}
|
| 155 |
+
{%- if detected_mode -%}
|
| 156 |
+
{%- set store.raw_mode = detected_mode -%}
|
| 157 |
+
{%- endif -%}
|
| 158 |
+
{%- set store.messages = store.messages + [{'role': msg.role, 'content': clean_txt, 'reasoning_content': msg.reasoning_content | default(''), 'tool_calls': msg.tool_calls | default([])}] -%}
|
| 159 |
+
{%- endfor -%}
|
| 160 |
+
{%- for msg in store.messages -%}
|
| 161 |
+
{%- if msg.role == 'user' or msg.role == 'developer' -%}
|
| 162 |
+
{%- set store.last_user_idx = loop.index0 -%}
|
| 163 |
+
{%- endif -%}
|
| 164 |
+
{%- endfor -%}
|
| 165 |
+
{%- set target_mode = store.raw_mode -%}
|
| 166 |
+
{%- if not target_mode and thinking_level is defined -%}
|
| 167 |
+
{%- set target_mode = thinking_level | string | lower | trim -%}
|
| 168 |
+
{%- elif not target_mode and reasoning_effort is defined -%}
|
| 169 |
+
{%- set target_mode = reasoning_effort | string | lower | trim -%}
|
| 170 |
+
{%- elif not target_mode and mode is defined -%}
|
| 171 |
+
{%- set target_mode = mode | string | lower | trim -%}
|
| 172 |
+
{%- endif -%}
|
| 173 |
+
{%- if not target_mode -%}
|
| 174 |
+
{%- set target_mode = '7' -%}
|
| 175 |
+
{%- endif -%}
|
| 176 |
+
{%- set direct_instruct = false -%}
|
| 177 |
+
{%- if target_mode.startswith('i') and target_mode | length > 1 -%}
|
| 178 |
+
{%- set direct_instruct = true -%}
|
| 179 |
+
{%- set target_mode = target_mode[1:] -%}
|
| 180 |
+
{%- endif -%}
|
| 181 |
+
{%- if target_mode in ['0', 'mortal', 'disabled', 'none', 'off', 'zero', 'direct', 'chat'] -%}
|
| 182 |
+
{%- set current_thinking = false -%}
|
| 183 |
+
{%- set reasoning_instructions = '' -%}
|
| 184 |
+
{%- elif target_mode in ['1', 'hermes', 'ulow', 'ultra-low', 'micro', 'minimal'] -%}
|
| 185 |
+
{%- set current_thinking = not direct_instruct -%}
|
| 186 |
+
{%- set reasoning_instructions = inst_hermes -%}
|
| 187 |
+
{%- elif target_mode in ['2', 'apollo', 'low', 'compact', 'fast'] -%}
|
| 188 |
+
{%- set current_thinking = not direct_instruct -%}
|
| 189 |
+
{%- set reasoning_instructions = inst_apollo -%}
|
| 190 |
+
{%- elif target_mode in ['3', 'artemis', 'lmed', 'low-medium', 'targeted'] -%}
|
| 191 |
+
{%- set current_thinking = not direct_instruct -%}
|
| 192 |
+
{%- set reasoning_instructions = inst_artemis -%}
|
| 193 |
+
{%- elif target_mode in ['4', 'athena', 'medium', 'med', 'balanced'] -%}
|
| 194 |
+
{%- set current_thinking = not direct_instruct -%}
|
| 195 |
+
{%- set reasoning_instructions = inst_athena -%}
|
| 196 |
+
{%- elif target_mode in ['5', 'prometheus', 'mhigh', 'medium-high', 'architect'] -%}
|
| 197 |
+
{%- set current_thinking = not direct_instruct -%}
|
| 198 |
+
{%- set reasoning_instructions = inst_prometheus -%}
|
| 199 |
+
{%- elif target_mode in ['6', 'solstice', 'high', 'deep', 'thorough'] -%}
|
| 200 |
+
{%- set current_thinking = not direct_instruct -%}
|
| 201 |
+
{%- set reasoning_instructions = inst_solstice -%}
|
| 202 |
+
{%- elif target_mode in ['7', 'hyperion', 'xhigh', 'extreme-high', 'rigorous', 'default'] -%}
|
| 203 |
+
{%- set current_thinking = not direct_instruct -%}
|
| 204 |
+
{%- set reasoning_instructions = inst_hyperion -%}
|
| 205 |
+
{%- elif target_mode in ['8', 'einstein', 'uhigh', 'ultra-high', 'solo-einstein'] -%}
|
| 206 |
+
{%- set current_thinking = not direct_instruct -%}
|
| 207 |
+
{%- set reasoning_instructions = inst_einstein -%}
|
| 208 |
+
{%- elif target_mode in ['9', 'oracle', 'amax', 'absolute-max', 'solo-oracle', 'proof'] -%}
|
| 209 |
+
{%- set current_thinking = not direct_instruct -%}
|
| 210 |
+
{%- set reasoning_instructions = inst_oracle -%}
|
| 211 |
+
{%- elif target_mode in ['swarm', 'einstein-swarm', '20-swarm', 'uhigh-swarm'] -%}
|
| 212 |
+
{%- set current_thinking = not direct_instruct -%}
|
| 213 |
+
{%- set reasoning_instructions = inst_swarm -%}
|
| 214 |
+
{%- elif target_mode in ['deep-swarm', 'oracle-swarm', 'council', 'amax-swarm', 'deep-research'] -%}
|
| 215 |
+
{%- set current_thinking = not direct_instruct -%}
|
| 216 |
+
{%- set reasoning_instructions = inst_deep_swarm -%}
|
| 217 |
+
{%- else -%}
|
| 218 |
+
{%- set current_thinking = not direct_instruct -%}
|
| 219 |
+
{%- set reasoning_instructions = inst_hyperion -%}
|
| 220 |
+
{%- endif -%}
|
| 221 |
+
{%- if store.explicit_thinking is defined and store.explicit_thinking is not none -%}
|
| 222 |
+
{%- set current_thinking = store.explicit_thinking -%}
|
| 223 |
+
{%- endif -%}
|
| 224 |
+
{{- bos -}}
|
| 225 |
+
{%- if reasoning_instructions -%}
|
| 226 |
+
{{- reasoning_instructions + '\n\n' -}}
|
| 227 |
+
{%- endif -%}
|
| 228 |
+
{%- if tools and tools is iterable and tools is not mapping -%}
|
| 229 |
+
{{ "## Tools\n\nYou have access to a set of tools to help answer the user's question. You can invoke tools by writing a \"<|DSML|tool_calls>\" block like the following:\n\n<|DSML|tool_calls>\n<|DSML|invoke name=\"$TOOL_NAME\">\n<|DSML|parameter name=\"$PARAMETER_NAME\" string=\"true|false\">$PARAMETER_VALUE</|DSML|parameter>\n...\n</|DSML|invoke>\n<|DSML|invoke name=\"$TOOL_NAME2\">\n...\n</|DSML|invoke>\n</|DSML|tool_calls>\n\nString parameters should be specified as is and set `string=\"true\"`. For all other types (numbers, booleans, arrays, objects), pass the value in JSON format and set `string=\"false\"`.\n\n### Available Tool Schemas\n\n" }}
|
| 230 |
+
{%- for tool in tools -%}
|
| 231 |
+
{%- if tool.function is defined -%}
|
| 232 |
+
{{- tool.function | tojson -}}
|
| 233 |
+
{%- else -%}
|
| 234 |
+
{{- tool | tojson -}}
|
| 235 |
+
{%- endif -%}
|
| 236 |
+
{%- if not loop.last -%}{{- '\n' -}}{%- endif -%}
|
| 237 |
+
{%- endfor -%}
|
| 238 |
+
{{ "\n\nYou MUST strictly follow the above defined tool name and parameter schemas to invoke tool calls.\n\n" }}
|
| 239 |
+
{%- endif -%}
|
| 240 |
+
{%- set ns = namespace(system_content='', has_system=false, prev_role='') -%}
|
| 241 |
+
{%- for msg in store.messages -%}
|
| 242 |
+
{%- if msg.role == 'system' -%}
|
| 243 |
+
{%- if not ns.has_system -%}
|
| 244 |
+
{%- set ns.system_content = msg.content -%}
|
| 245 |
+
{%- set ns.has_system = true -%}
|
| 246 |
+
{%- else -%}
|
| 247 |
+
{%- set ns.system_content = ns.system_content + '\n\n' + msg.content -%}
|
| 248 |
+
{%- endif -%}
|
| 249 |
+
{%- endif -%}
|
| 250 |
+
{%- endfor -%}
|
| 251 |
+
{%- if ns.has_system and ns.system_content -%}
|
| 252 |
+
{{- ns.system_content -}}
|
| 253 |
+
{%- endif -%}
|
| 254 |
+
{%- for msg in store.messages -%}
|
| 255 |
+
{%- set idx = loop.index0 -%}
|
| 256 |
+
{%- if msg.role == 'user' or msg.role == 'developer' -%}
|
| 257 |
+
{{- '<|User|>' + msg.content -}}
|
| 258 |
+
{%- set ns.prev_role = 'user' -%}
|
| 259 |
+
{%- elif msg.role == 'assistant' -%}
|
| 260 |
+
{%- set r_content = msg.reasoning_content | trim -%}
|
| 261 |
+
{%- set m_content = msg.content | trim -%}
|
| 262 |
+
{%- if r_content and (preserve_thinking is undefined or preserve_thinking or idx > store.last_user_idx) -%}
|
| 263 |
+
{{- '<|Assistant|><think>' + r_content + '</think>' + m_content -}}
|
| 264 |
+
{%- else -%}
|
| 265 |
+
{{- '<|Assistant|>' + m_content -}}
|
| 266 |
+
{%- endif -%}
|
| 267 |
+
{%- if msg.tool_calls and msg.tool_calls is iterable and msg.tool_calls is not mapping -%}
|
| 268 |
+
{{- '\n\n<|DSML|tool_calls>' -}}
|
| 269 |
+
{%- for tc in msg.tool_calls -%}
|
| 270 |
+
{%- set tc_name = tc.function.name if tc.function is defined else tc.name -%}
|
| 271 |
+
{%- set tc_args = tc.function.arguments if tc.function is defined else tc.arguments -%}
|
| 272 |
+
{{- '\n<|DSML|invoke name="' + tc_name + '">' -}}
|
| 273 |
+
{%- if tc_args is mapping -%}
|
| 274 |
+
{%- for p_name, p_val in tc_args.items() -%}
|
| 275 |
+
{%- if p_val is string -%}
|
| 276 |
+
{{- '\n<|DSML|parameter name="' + p_name + '" string="true">' + p_val + '</|DSML|parameter>' -}}
|
| 277 |
+
{%- else -%}
|
| 278 |
+
{{- '\n<|DSML|parameter name="' + p_name + '" string="false">' + (p_val | tojson) + '</|DSML|parameter>' -}}
|
| 279 |
+
{%- endif -%}
|
| 280 |
+
{%- endfor -%}
|
| 281 |
+
{%- elif tc_args is string -%}
|
| 282 |
+
{{- '\n' + tc_args -}}
|
| 283 |
+
{%- endif -%}
|
| 284 |
+
{{- '\n</|DSML|invoke>' -}}
|
| 285 |
+
{%- endfor -%}
|
| 286 |
+
{{- '\n</|DSML|tool_calls>' -}}
|
| 287 |
+
{%- endif -%}
|
| 288 |
+
{{- eos -}}
|
| 289 |
+
{%- set ns.prev_role = 'assistant' -%}
|
| 290 |
+
{%- elif msg.role == 'tool' -%}
|
| 291 |
+
{%- if ns.prev_role != 'user' -%}
|
| 292 |
+
{{- '<|User|>' -}}
|
| 293 |
+
{%- endif -%}
|
| 294 |
+
{{- '<tool_result>' + msg.content + '</tool_result>' -}}
|
| 295 |
+
{%- set ns.prev_role = 'user' -%}
|
| 296 |
+
{%- endif -%}
|
| 297 |
+
{%- endfor -%}
|
| 298 |
+
{%- if add_generation_prompt -%}
|
| 299 |
+
{%- if current_thinking -%}
|
| 300 |
+
{{- '<|Assistant|><think>\n' -}}
|
| 301 |
+
{%- else -%}
|
| 302 |
+
{{- '<|Assistant|></think>' -}}
|
| 303 |
+
{%- endif -%}
|
| 304 |
+
{%- endif -%}
|