Firworks/Step-Audio-R1-nvfp4
217
1{%- if tools %}2 {{- '<|BOT|>system3' }}4 {%- if messages[0]['role'] == 'system' %}5 {{- messages[0]['content'] + '<|EOT|>' }}6 {%- else %}7 {{- 'You are a helpful assistant. Please think step by step and provide your reasoning process within <think> </think> tags, followed by your final answer. Format: <think>your reasoning here</think>your final answer<|EOT|>' }}8 {%- endif %}9 {{- '<|BOT|>' }}10 {{- "tool_json_schemas11" }}12 {{- tools | tojson }}13 {{- '<|EOT|>' }}14{%- else %}15 {%- if messages[0]['role'] == 'system' %}16 {{- '<|BOT|>system17' + messages[0]['content'] + '<|EOT|>' }}18 {%- else %}19 {{- '<|BOT|>system20You are a helpful assistant. Please think step by step and provide your reasoning process within <think> </think> tags, followed by your final answer. Format: <think>your reasoning here</think>your final answer<|EOT|>' }}21 {%- endif %}22{%- endif %}23{%- for message in messages %}24 {%- if message["role"] == "user" %}25 {{- '<|BOT|>human26' + message["content"] + '<|EOT|>' }}27 {%- elif (message["role"] == "system" and not loop.first) or (message["role"] == "assistant" and not message["tool_calls"]) %}28 {{- '<|BOT|>' + message["role"] + '29' + message["content"] + '<|EOT|>' }}30 {%- elif message["role"] == "assistant" %}31 {{- '<|BOT|>' + message["role"] + '32' }}33 {%- if message["content"] %}34 {{- message["content"] }}35 {%- endif %}36 {%- for tool_call in message.tool_calls %}37 {%- if tool_call["function"] is defined %}38 {%- set tool_call = tool_call["function"] %}39 {%- endif %}40 {{- '<|CALL_START|>' + 'function41' + tool_call["name"] + '42' }}43 {{- tool_call["arguments"] | tojson }}44 {{- '<|CALL_END|>' }}45 {%- endfor %}46 {{- '<|EOT|>' }}47 {%- elif message["role"] == "tool" %}48 {{- '<|BOT|>' }}49 {%- set ns = namespace(function_name="tool") %}50 {%- if message["tool_call_id"] %}51 {%- for prev_msg in messages %}52 {%- if prev_msg["role"] == "assistant" and prev_msg["tool_calls"] %}53 {%- for tool_call in prev_msg["tool_calls"] %}54 {%- if tool_call["id"] == message["tool_call_id"] %}55 {%- if tool_call["function"] is defined %}56 {%- set ns.function_name = tool_call["function"]["name"] %}57 {%- endif %}58 {%- endif %}59 {%- endfor %}60 {%- endif %}61 {%- endfor %}62 {%- endif %}63 {{- 'function_output64' + ns.function_name + '65' }}66 {{- message["content"] }}67 {{- '<|EOT|>' }}68 {%- endif %}69{%- endfor %}70{%- if add_generation_prompt %}71 {{- '<|BOT|>assistant72<think>73' }}74{%- endif %}