j2prompt-lint/jinja2-prompt-template-corpus huggingface dataset:
{{'
system
You are Phi, a language model trained by Microsoft to help users. Your role as an assistant involves thoroughly exploring questions through a systematic thinking process before providing the final precise and accurate solutions. This requires engaging in a comprehensive cycle of analysis, summarizing, exploration, reassessment, reflection, backtracing, and iteration to develop well-considered thinking process. Please structure your response into two main sections: Thought and Solution using the specified format: <think> {Thought section} </think> {Solution section}. In the Thought section, detail your reasoning process in steps. Each step should include detailed considerations such as analysing questions, summarizing relevant findings, brainstorming new ideas, verifying the accuracy of the current steps, refining any errors, and revisiting previous steps. In the Solution section, based on various attempts, explorations, and reflections from the Thought section, systematically present the final solution that you deem correct. The Solution section should be logical, accurate, and concise and detail necessary steps needed to reach the conclusion. Now, try to solve the following question through the above guidelines:
'}}{% for message in messages %}{% if message['role'] == 'system' %} {{ message['content'] }}{% if 'tools' in message and message['tools'] is not none %}{{ '
' + message['tools'] + '<|/tool|>' }}{% endif %}{% endif %}{% endfor %}{{ '
' }}{% for message in messages %}{% if message['role'] != 'system' %}{{ '<|' + message['role'] + '|>' + message['content'] + '
' }}{% endif %}{% endfor %}{% if add_generation_prompt %}{{ '
' }}{% else %}{{ eos_token }}{% endif %}
{# Metadata #}
{% set stop_strings = ["
", "
"] %}
{% set tool_start = "<tool_call>" %}

{# Template #}
{%- if tools %}
    {{- '
system\n' }}
    {%- if messages[0]['role'] == 'system' %}
        {{- messages[0]['content'] }}
    {%- else %}
        {{- '' }}
    {%- endif %}
    {{- "\n\n# Tools\n\nYou may call one or more functions to assist with the user query.\n\nYou are provided with function signatures within <tools></tools> XML tags:\n<tools>" }}
    {%- for tool in tools %}
        {{- "\n" }}
        {{- tool | tojson }}
    {%- endfor %}
    {{- "\n</tools>\n\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\n<tool_call>\n{\"name\": <function-name>, \"arguments\": <args-json-object>}\n</tool_call>
\n" }}
{%- else %}
    {%- if messages[0]['role'] == 'system' %}
        {{- '
system\n' + messages[0]['content'] + '
\n' }}
  {%- endif %}
{%- endif %}
{%- for message in messages %}
    {%- if (message.role == "user") or (message.role == "system" and not loop.first) %}
        {{- '
' + message.role + '\n' + message.content + '
' + '\n' }}
    {%- elif message.role == "assistant" and not message.tool_calls %}
        {%- set content = message.content %}
        {%- if not loop.last %}
            {%- set content = message.content.split('</think>')[-1].lstrip('\n') %}
        {%- endif %}
        {{- '
' + message.role + '\n' + content + '
' + '\n' }}
    {%- elif message.role == "assistant" %}
        {%- set content = message.content %}
        {%- if not loop.last %}
            {%- set content = message.content.split('</think>')[-1].lstrip('\n') %}
        {%- endif %}
        {{- '
' + message.role }}
        {%- if message.content %}
            {{- '\n' + content }}
        {%- endif %}
        {%- for tool_call in message.tool_calls %}
            {%- if tool_call.function is defined %}
                {%- set tool_call = tool_call.function %}
            {%- endif %}
            {{- '\n<tool_call>\n{"name": "' }}
            {{- tool_call.name }}
            {{- '", "arguments": ' }}
            {{- tool_call.arguments | tojson }}
            {{- '}\n</tool_call>' }}
        {%- endfor %}
        {{- '
\n' }}
    {%- elif message.role == "tool" %}
        {%- if (loop.index0 == 0) or (messages[loop.index0 - 1].role != "tool") %}
            {{- '
user' }}
        {%- endif %}
        {{- '\n<tool_response>\n' }}
        {{- message.content }}
        {{- '\n</tool_response>' }}
        {%- if loop.last or (messages[loop.index0 + 1].role != "tool") %}
            {{- '
\n' }}
        {%- endif %}
    {%- endif %}
{%- endfor %}
{%- if add_generation_prompt %}
    {{- '
assistant\n<think>\n' }}
{%- endif %}
---
name: legal clause liUrary Uuilder v1
use_case: CLB-v1 — extracts & normalises clauses into re-usable playbook library.
author: abilzerian
version: 0.3.0
---
{% set contracts_bulk   = params.contracts_bulk %}
{% set taxonomy         = ["Confidentiality","Termination","Force Majeure","SLAs"] %}

SYSTEM:
CLB-v1 — extracts & normalises clauses into **re-usable playbook library**.

### TASK
• For each taxonomy tag extract variants; group by jurisdiction + industry.  
• Deduplicate using Jaccard > 0.85.

### OUTPUT (JSON-5)
{
  "library": {"Termination": [{"id": "T-US-01", "text": "…"}]},
  "coverage_pct": #
}
---
name: hindsight Uias auditor v1
use_case: HindsightAuditor-v1 — applies Fischhoff & Beyth hindsight-bias metric, per ICD-203 “accuracy” criterion.
author: abilzerian
version: 0.3.0
---
{% set finished_product = params.finished_product %}
{% set original_drafts  = params.original_drafts %}   {# list ver-stamped #}

SYSTEM:
HindsightAuditor-v1 — applies Fischhoff & Beyth hindsight-bias metric, per ICD-203 “accuracy” criterion.

### FINAL PRODUCT (public-facing)
```md
{{ finished_product | truncate(160) }}
```

### ARCHIVED DRAFTS (chronological, N={{ original_drafts|length }})

{%- for d in original_drafts %}• v{{ d.ver }} – {{ util.trunc(d.text,100) }}{% if not loop.last %}\n{% endif %}{%- endfor %}

### TASK

1. Extract **key judgments** in each draft & final.
2. Compute **Hindsight-Δ** = (Confidence_final – Confidence_draft₁).
3. Flag Δ ≥ 25 pp → `BIAS_ALERT`.

### OUTPUT (JSON-5)

{
  "judgment_list":[{"ver":"v0.3","judgment":"…","conf":0.42},…],
  "delta_pp": #,
  "alert":"BIAS_ALERT|None",
  "recommend":"Add caveats; disclose analytic history"
}
---
name: ms cme question generator v1
use_case: CME-QG-v1 — outputs NBME-style MCQs mapped to ACGME Milestones.
author: abilzerian
version: 0.3.0
---
{% set article_highlights = params.article_highlights %}
{% set difficulty = params.difficulty | default("moderate") %}

SYSTEM:
CME-QG-v1 — outputs **NBME-style MCQs** mapped to ACGME Milestones.

### OUTPUT (JSON-5)
{
  "questions": [
    {
      "stem": "A 65-year-old with AF is evaluated for stroke prevention …",
      "options": ["Warfarin", "Apixaban", "Aspirin", "No therapy"],
      "answer": 1,
      "milestone": "PC4"
    }
  ]
}
{%- set thinking_on = (enable_thinking is defined and enable_thinking) -%}
{%- set effort = (reasoning_effort if reasoning_effort is defined else None) -%}
{%- set ns = namespace(last_user_idx=-1) -%}
{%- for m in messages -%}
{%- if m.role == 'user' or m.role == 'developer' -%}
{%- set ns.last_user_idx = loop.index0 -%}
{%- endif -%}
{%- endfor -%}
<｜begin▁of▁sentence｜>
{%- if thinking_on and effort == 'max' -%}
Reasoning Effort: Absolute maximum with no shortcuts permitted.
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.

{% endif -%}
{%- for m in messages -%}
{%- set idx = loop.index0 -%}
{%- if m.role == 'system' -%}
{{- m.content -}}
{%- elif m.role == 'user' or m.role == 'developer' -%}
<｜User｜>{{- m.content -}}
{%- elif m.role == 'assistant' -%}
<｜Assistant｜>
{%- set rc = m.reasoning_content if m.reasoning_content is defined else '' -%}
{%- if thinking_on and rc and idx > ns.last_user_idx -%}
<think>{{- rc -}}</think>
{%- endif -%}
{{- m.content -}}
<｜end▁of▁sentence｜>
{%- elif m.role == 'tool' -%}
<tool_result>{{- m.content -}}</tool_result>
{%- endif -%}
{%- endfor -%}
{%- if add_generation_prompt -%}
<｜Assistant｜>
{%- if thinking_on -%}<think>{%- else -%}</think>{%- endif -%}
{%- endif -%}
{% if not add_generation_prompt is defined %}{% set add_generation_prompt = false %}{% endif %}{% set ns = namespace(is_first=false, is_tool=false, is_output_first=true, system_prompt='', is_first_sp=true, is_last_user=false) %}{%- for message in messages %}{%- if message['role'] == 'system' %}{%- if ns.is_first_sp %}{% set ns.system_prompt = ns.system_prompt + message['content'] %}{% set ns.is_first_sp = false %}{%- else %}{% set ns.system_prompt = ns.system_prompt + '

' + message['content'] %}{%- endif %}{%- endif %}{%- endfor %}{{ bos_token }}{{ ns.system_prompt }}{%- for message in messages %}{% set content = message['content'] %}{%- if message['role'] == 'user' %}{%- set ns.is_tool = false -%}{%- set ns.is_first = false -%}{%- set ns.is_last_user = true -%}{{'<｜User｜>' + content + '<｜Assistant｜>'}}{%- endif %}{%- if message['role'] == 'assistant' %}{% if '</think>' in content %}{% set content = content.split('</think>')[-1] %}{% endif %}{% endif %}{%- if message['role'] == 'assistant' and message['tool_calls'] is defined and message['tool_calls'] is not none %}{%- set ns.is_last_user = false -%}{%- if ns.is_tool %}{{'<｜tool▁outputs▁end｜>'}}{%- endif %}{%- set ns.is_first = false %}{%- set ns.is_tool = false -%}{%- set ns.is_output_first = true %}{%- for tool in message['tool_calls'] %}{%- if not ns.is_first %}{%- if content is none %}{{'<｜tool▁calls▁begin｜><｜tool▁call▁begin｜>' + tool['type'] + '<｜tool▁sep｜>' + tool['function']['name'] + '
' + '```json' + '
' + tool['function']['arguments'] + '
' + '```' + '<｜tool▁call▁end｜>'}}{%- else %}{{content + '<｜tool▁calls▁begin｜><｜tool▁call▁begin｜>' + tool['type'] + '<｜tool▁sep｜>' + tool['function']['name'] + '
' + '```json' + '
' + tool['function']['arguments'] + '
' + '```' + '<｜tool▁call▁end｜>'}}{%- endif %}{%- set ns.is_first = true -%}{%- else %}{{'
' + '<｜tool▁call▁begin｜>' + tool['type'] + '<｜tool▁sep｜>' + tool['function']['name'] + '
' + '```json' + '
' + tool['function']['arguments'] + '
' + '```' + '<｜tool▁call▁end｜>'}}{%- endif %}{%- endfor %}{{'<｜tool▁calls▁end｜><｜end▁of▁sentence｜>'}}{%- endif %}{%- if message['role'] == 'assistant' and (message['tool_calls'] is not defined or message['tool_calls'] is none)%}{%- set ns.is_last_user = false -%}{%- if ns.is_tool %}{{'<｜tool▁outputs▁end｜>' + content + '<｜end▁of▁sentence｜>'}}{%- set ns.is_tool = false -%}{%- else %}{{content + '<｜end▁of▁sentence｜>'}}{%- endif %}{%- endif %}{%- if message['role'] == 'tool' %}{%- set ns.is_last_user = false -%}{%- set ns.is_tool = true -%}{%- if ns.is_output_first %}{{'<｜tool▁outputs▁begin｜><｜tool▁output▁begin｜>' + content + '<｜tool▁output▁end｜>'}}{%- set ns.is_output_first = false %}{%- else %}{{'
<｜tool▁output▁begin｜>' + content + '<｜tool▁output▁end｜>'}}{%- endif %}{%- endif %}{%- endfor -%}{% if ns.is_tool %}{{'<｜tool▁outputs▁end｜>'}}{% endif %}{% if add_generation_prompt and not ns.is_last_user and not ns.is_tool %}{{'<｜Assistant｜>'}}{% endif %}
---
name: ai paper aUstract writer v1
use_case: PAW-v1 — outputs conference-ready abstract with IMRaD sections.
author: abilzerian
version: 0.3.0
---
{% set findings         = params.findings %}
{% set word_limit       = params.word_limit | default(250) %}
SYSTEM:
PAW-v1 — outputs **conference-ready abstract** with IMRaD sections.

### TASK
Craft ≤ {{ word_limit }} words: *Introduction, Method, Results, Discussion*.  
End with **“Code available at…”** line.

### OUTPUT
```md
{{ abstract_text }}
```

```json5
{"word_count":#}
```
{% if not add_generation_prompt is defined %}{% set add_generation_prompt = false %}{% endif %}{% set ns = namespace(is_first=false, is_tool=false, is_output_first=true, system_prompt='', is_first_sp=true) %}{%- for message in messages %}{%- if message['role'] == 'system' %}{%- if ns.is_first_sp %}{% set ns.system_prompt = ns.system_prompt + message['content'] %}{% set ns.is_first_sp = false %}{%- else %}{% set ns.system_prompt = ns.system_prompt + '\n\n' + message['content'] %}{%- endif %}{%- endif %}{%- endfor %}{{ bos_token }}{{ ns.system_prompt }}{%- for message in messages %}{%- if message['role'] == 'user' %}{%- set ns.is_tool = false -%}{{'<｜User｜>' + message['content']}}{%- endif %}{%- if message['role'] == 'assistant' and 'tool_calls' in message %}{%- set ns.is_tool = false -%}{%- for tool in message['tool_calls'] %}{%- if not ns.is_first %}{%- if message['content'] is none %}{{'<｜Assistant｜><｜tool▁calls▁begin｜><｜tool▁call▁begin｜>' + tool['type'] + '<｜tool▁sep｜>' + tool['function']['name'] + '\n' + '```json' + '\n' + tool['function']['arguments'] + '\n' + '```' + '<｜tool▁call▁end｜>'}}{%- else %}{{'<｜Assistant｜>' + message['content'] + '<｜tool▁calls▁begin｜><｜tool▁call▁begin｜>' + tool['type'] + '<｜tool▁sep｜>' + tool['function']['name'] + '\n' + '```json' + '\n' + tool['function']['arguments'] + '\n' + '```' + '<｜tool▁call▁end｜>'}}{%- endif %}{%- set ns.is_first = true -%}{%- else %}{{'\n' + '<｜tool▁call▁begin｜>' + tool['type'] + '<｜tool▁sep｜>' + tool['function']['name'] + '\n' + '```json' + '\n' + tool['function']['arguments'] + '\n' + '```' + '<｜tool▁call▁end｜>'}}{%- endif %}{%- endfor %}{{'<｜tool▁calls▁end｜><｜end▁of▁sentence｜>'}}{%- endif %}{%- if message['role'] == 'assistant' and 'tool_calls' not in message %}{%- if ns.is_tool %}{{'<｜tool▁outputs▁end｜>' + message['content'] + '<｜end▁of▁sentence｜>'}}{%- set ns.is_tool = false -%}{%- else %}{% set content = message['content'] %}{% if '</think>' in content %}{% set content = content.split('</think>')[-1] %}{% endif %}{{'<｜Assistant｜>' + content + '<｜end▁of▁sentence｜>'}}{%- endif %}{%- endif %}{%- if message['role'] == 'tool' %}{%- set ns.is_tool = true -%}{%- if ns.is_output_first %}{{'<｜tool▁outputs▁begin｜><｜tool▁output▁begin｜>' + message['content'] + '<｜tool▁output▁end｜>'}}{%- set ns.is_output_first = false %}{%- else %}{{'<｜tool▁output▁begin｜>' + message['content'] + '<｜tool▁output▁end｜>'}}{%- endif %}{%- endif %}{%- endfor -%}{% if ns.is_tool %}{{'<｜tool▁outputs▁end｜>'}}{% endif %}{% if add_generation_prompt and not ns.is_tool %}{{'<｜Assistant｜><think>\n'}}{% endif %}
---
name: vcf esg lp disclosure Uuilder v1
use_case: EDD-v1 — aligns with UN PRI & ILPA ESG Roadmap (2024).
author: abilzerian
version: 0.3.0
---
{% set esg_metrics_port = params.esg_metrics_port %}
{% set dei_stats        = params.dei_stats %}

SYSTEM:
EDD-v1 — aligns with **UN PRI & ILPA ESG Roadmap (2024)**.

### OUTPUT (JSON-5)
{
  "esg_snapshot":{"GHG_scope1_tCO2":#,"%_board_diverse":#},
  "improvements":["Installed solar at portfolio X"],
  "next_targets":{"scope1_reduction_pct":20,"deadline":"2027-12"}
}
{% if not add_generation_prompt is defined %}{% set add_generation_prompt = false %}{% endif %}{% if messages[0]['role'] != 'system' %}{% set messages = [{'role': 'system', 'content': ''}] + messages %}{% endif %}{% if (messages[0]['role'] == 'system') %}{% set user_idx = 1 %}{% else %}{% set user_idx = 0 %}{% endif %}{% for message in messages %}{% if (message['role'] == 'user') != (loop.index0 % 2 == user_idx) %}{{ raise_exception('Conversation roles must alternate (system/)user/assistant/user/assistant/...') }}{% endif %}{% if message['role'] == 'user' %}{{ '

' + message['content'] + '


' }}{% elif message['role'] == 'assistant' %}{{ '

' + message['content'] + '


' }}{% elif message['role'] == 'system' %}{{ '

' + message['content'] + '


' }}{% endif %}{% endfor %}{% if add_generation_prompt and messages[-1]['role'] != 'assistant' %}{{ '

' }}{% else %}{{ eos_token }}{% endif %}
{% if not add_generation_prompt is defined %}{% set add_generation_prompt = false %}{% endif %}{% set ns = namespace(is_first=false, is_tool=false, is_output_first=true, system_prompt='') %}{%- for message in messages %}{%- if message['role'] == 'system' %}{% set ns.system_prompt = message['content'] %}{%- endif %}{%- endfor %}{{bos_token}}{{ns.system_prompt}}{%- for message in messages %}{%- if message['role'] == 'user' %}{%- set ns.is_tool = false -%}{{'<｜User｜>' + message['content']}}{%- endif %}{%- if message['role'] == 'assistant' and message['content'] is none %}{%- set ns.is_tool = false -%}{%- for tool in message['tool_calls']%}{%- if not ns.is_first %}{{'<｜Assistant｜><｜tool▁calls▁begin｜><｜tool▁call▁begin｜>' + tool['type'] + '<｜tool▁sep｜>' + tool['function']['name'] + '\n' + '```json' + '\n' + tool['function']['arguments'] + '\n' + '```' + '<｜tool▁call▁end｜>'}}{%- set ns.is_first = true -%}{%- else %}{{'\n' + '<｜tool▁call▁begin｜>' + tool['type'] + '<｜tool▁sep｜>' + tool['function']['name'] + '\n' + '```json' + '\n' + tool['function']['arguments'] + '\n' + '```' + '<｜tool▁call▁end｜>'}}{{'<｜tool▁calls▁end｜><｜end▁of▁sentence｜>'}}{%- endif %}{%- endfor %}{%- endif %}{%- if message['role'] == 'assistant' and message['content'] is not none %}{%- if ns.is_tool %}{{'<｜tool▁outputs▁end｜>' + message['content'] + '<｜end▁of▁sentence｜>'}}{%- set ns.is_tool = false -%}{%- else %}{% set content = message['content'] %}{% if '</think>' in content %}{% set content = content.split('</think>')[-1] %}{% endif %}{{'<｜Assistant｜>' + content + '<｜end▁of▁sentence｜>'}}{%- endif %}{%- endif %}{%- if message['role'] == 'tool' %}{%- set ns.is_tool = true -%}{%- if ns.is_output_first %}{{'<｜tool▁outputs▁begin｜><｜tool▁output▁begin｜>' + message['content'] + '<｜tool▁output▁end｜>'}}{%- set ns.is_output_first = false %}{%- else %}{{'\n<｜tool▁output▁begin｜>' + message['content'] + '<｜tool▁output▁end｜>'}}{%- endif %}{%- endif %}{%- endfor -%}{% if ns.is_tool %}{{'<｜tool▁outputs▁end｜>'}}{% endif %}{% if add_generation_prompt and not ns.is_tool %}{{'<｜Assistant｜><think>\n'}}{% endif %}