Model: MagicalAlchemist/Apriel-Nemotron-15b-Thinker-Magic_decensored-v2_MPOA Source: Original Platform
69 lines
3.7 KiB
Django/Jinja
69 lines
3.7 KiB
Django/Jinja
{%- set reasoning_prompt = 'You are a thoughtful and systematic AI assistant built by ServiceNow Language Models (SLAM) lab. Before providing an answer, analyze the problem carefully and present your reasoning step by step. After explaining your thought process, provide the final solution in the following format: [BEGIN FINAL RESPONSE] ... [END FINAL RESPONSE].' -%}
|
|
{%- set reasoning_asst_turn_start = 'Here are my reasoning steps:\n' -%}
|
|
{%- set available_tools_string = '' -%}
|
|
|
|
{%- if tools is defined and tools is not none and tools|length > 0 -%}
|
|
{%- set available_tools_string -%}
|
|
You are provided with function signatures within <available_tools></available_tools> XML tags. You may call one or more functions to assist with the user query. Don't make assumptions about the arguments. You should infer the argument values from previous user responses and the system message. Here are the available tools: <available_tools>{% for tool in tools %}{{ tool|tojson }}{% if not loop.last %}, {% endif %}{% endfor %}</available_tools>.
|
|
|
|
Return all function calls as a list of json objects within <tool_calls></tool_calls> XML tags. Each json object should contain a function name and arguments as follows: <tool_calls>[{"name": <function-name-1>, "arguments": <args-dict-1>}, {"name": <function-name-2>, "arguments": <args-dict-2>},...]</tool_calls>
|
|
{%- endset -%}
|
|
{%- endif -%}
|
|
|
|
{%- if messages[0]['role'] != 'system' -%}
|
|
{{- '<|system|>\n' + reasoning_prompt -}}
|
|
{%- if available_tools_string|length > 0 -%}
|
|
{{- '\n\n' + available_tools_string -}}
|
|
{%- endif -%}
|
|
{{- '\n<|end|>\n' -}}
|
|
{%- endif -%}
|
|
|
|
{%- for message in messages -%}
|
|
{%- if message['role'] == 'user' -%}
|
|
{{- '<|user|>\n' + message['content'] + '\n<|end|>\n' -}}
|
|
|
|
{%- elif message['role'] == 'system' -%}
|
|
{{- '<|system|>\n' + reasoning_prompt + '\n\n' + message['content'] -}}
|
|
{%- if available_tools_string|length > 0 -%}
|
|
{{- '\n' + available_tools_string -}}
|
|
{%- endif -%}
|
|
{{- '\n<|end|>\n' -}}
|
|
|
|
{%- elif message['role'] == 'assistant' -%}
|
|
{{- '<|assistant|>\n' -}}
|
|
{%- if message['content'] is defined and message['content'] is not none -%}
|
|
{{- message['content'] -}}
|
|
{%- elif message['chosen'] is defined and message['chosen'] is not none and message['chosen']|length > 0 -%}
|
|
{{- message['chosen'][0] -}}
|
|
{%- endif -%}
|
|
|
|
{%- if message['tool_calls'] is defined and message['tool_calls'] is not none and message['tool_calls']|length > 0 -%}
|
|
{{- '\n<tool_calls>[' -}}
|
|
{%- for tool_call in message['tool_calls'] -%}
|
|
{{- '{"name": "' + tool_call['function']['name'] + '", "arguments": ' -}}
|
|
{%- if tool_call['function']['arguments'] is string -%}
|
|
{{- tool_call['function']['arguments'] -}}
|
|
{%- else -%}
|
|
{{- tool_call['function']['arguments']|tojson -}}
|
|
{%- endif -%}
|
|
{%- if tool_call['id'] is defined and tool_call['id'] is not none -%}
|
|
{{- ', "id": "' + tool_call['id'] + '"' -}}
|
|
{%- endif -%}
|
|
{{- '}' -}}
|
|
{%- if not loop.last -%}{{- ', ' -}}{%- endif -%}
|
|
{%- endfor -%}
|
|
{{- ']</tool_calls>' -}}
|
|
{%- endif -%}
|
|
|
|
{%- if not loop.last -%}
|
|
{{- '\n<|end|>\n' -}}
|
|
{%- endif -%}
|
|
|
|
{%- elif message['role'] == 'tool' -%}
|
|
{{- '<|tool_result|>\n' + message['content']|string + '\n<|end|>\n' -}}
|
|
{%- endif -%}
|
|
|
|
{%- if loop.last and add_generation_prompt is defined and add_generation_prompt and message['role'] != 'assistant' -%}
|
|
{{- '<|assistant|>\n' + reasoning_asst_turn_start -}}
|
|
{%- endif -%}
|
|
{%- endfor -%} |