Helion-V2.0-Thinking / chat_template.jinja
Trouter-Library's picture
Update chat_template.jinja
1439132 verified
{%- set ns = namespace(
has_system=false,
has_images=false,
has_tools=false,
message_count=0,
image_count=0,
tool_call_count=0
) -%}
{%- if messages[0]['role'] == 'system' -%}
{%- set system_message = messages[0]['content'] -%}
{%- set loop_messages = messages[1:] -%}
{%- set ns.has_system = true -%}
{%- else -%}
{%- set system_message = 'You are Helion, an advanced AI assistant with the following capabilities:
1. Vision Understanding: You can analyze images, charts, diagrams, documents, and screenshots. Use the <image> token to reference visual inputs.
2. Tool Use: You can call functions and use tools by responding with valid JSON in the format: {"tool": "tool_name", "parameters": {...}}
3. Long Context: You can process and remember up to 200,000 tokens of conversation history.
4. Reasoning: You excel at step-by-step logical reasoning, mathematical problem-solving, and code generation.
5. Multilingual: You can communicate in 12+ languages with strong performance.
Guidelines:
- Always be helpful, respectful, and honest
- Provide accurate, well-reasoned responses
- Cite sources when referencing external information
- Admit uncertainty when appropriate
- Refuse harmful or inappropriate requests
- Use tools when they would be helpful
- Break down complex problems into steps
- Consider multiple perspectives' -%}
{%- set loop_messages = messages -%}
{%- endif -%}
{{- bos_token -}}
{%- if system_message and system_message|length > 0 -%}
<|system|>
{{- system_message }}
</s>
{%- endif -%}
{%- for message in loop_messages -%}
{%- set ns.message_count = ns.message_count + 1 -%}
{%- if message['role'] == 'user' -%}
<|user|>
{%- if message.get('images') -%}
{%- set ns.has_images = true -%}
{%- if message['images'] is iterable and message['images'] is not string -%}
{%- for image in message['images'] -%}
{%- set ns.image_count = ns.image_count + 1 -%}
<image>
{%- endfor -%}
{%- else -%}
{%- set ns.image_count = ns.image_count + 1 -%}
<image>
{%- endif -%}
{%- endif -%}
{%- if message.get('documents') -%}
<documents>
{%- for doc in message['documents'] -%}
<document id="{{ doc.get('id', loop.index) }}" title="{{ doc.get('title', 'Document ' ~ loop.index) }}">
{{ doc.get('content', '') }}
</document>
{%- endfor -%}
</documents>
{%- endif -%}
{%- if message.get('context') -%}
<context>
{{ message['context'] }}
</context>
{%- endif -%}
{{- message['content'] -}}
{%- if message.get('constraints') -%}
<constraints>
{{ message['constraints'] }}
</constraints>
{%- endif -%}
</s>
{%- elif message['role'] == 'assistant' -%}
<|assistant|>
{%- if message.get('reasoning') -%}
<reasoning>
{{ message['reasoning'] }}
</reasoning>
{%- endif -%}
{%- if message.get('tool_calls') -%}
{%- set ns.has_tools = true -%}
{%- for tool_call in message['tool_calls'] -%}
{%- set ns.tool_call_count = ns.tool_call_count + 1 -%}
<tool_call id="{{ tool_call.get('id', 'call_' ~ ns.tool_call_count) }}">
{"tool": "{{ tool_call.get('name', tool_call.get('tool', 'unknown')) }}", "parameters": {{ tool_call.get('parameters', tool_call.get('arguments', '{}')) | tojson }}}
</tool_call>
{%- endfor -%}
{%- endif -%}
{{- message['content'] -}}
{%- if message.get('code_execution') -%}
<code_execution language="{{ message['code_execution'].get('language', 'python') }}">
{{ message['code_execution'].get('code', '') }}
</code_execution>
{%- endif -%}
{%- if message.get('citations') -%}
<citations>
{%- for citation in message['citations'] -%}
- [{{ loop.index }}] {{ citation.get('source', 'Unknown source') }}{% if citation.get('url') %}: {{ citation['url'] }}{% endif %}
{%- endfor -%}
</citations>
{%- endif -%}
</s>
{%- elif message['role'] == 'tool' -%}
<|tool|>
{%- if message.get('tool_call_id') -%}
<tool_result id="{{ message['tool_call_id'] }}">
{%- else -%}
<tool_result>
{%- endif -%}
{%- if message.get('result') -%}
{{ message['result'] | tojson if message['result'] is mapping else message['result'] }}
{%- else -%}
{{ message['content'] }}
{%- endif -%}
{%- if message.get('error') -%}
<error>
{{ message['error'] }}
</error>
{%- endif -%}
</tool_result>
</s>
{%- elif message['role'] == 'function' -%}
<|function|>
<function_response name="{{ message.get('name', 'unknown') }}">
{{ message['content'] }}
</function_response>
</s>
{%- elif message['role'] == 'thought' -%}
<|thought|>
{{ message['content'] }}
</s>
{%- elif message['role'] == 'observation' -%}
<|observation|>
{{ message['content'] }}
</s>
{%- else -%}
<|{{ message['role'] }}|>
{{ message['content'] }}
</s>
{%- endif -%}
{%- endfor -%}
{%- if add_generation_prompt -%}
{%- if ns.has_tools -%}
<|assistant|>
{%- else -%}
<|assistant|>
{%- endif -%}
{%- endif -%}