Gemma3-Rhino-27B-RAG / chat_template.json
QomSSLab's picture
(Trained with Unsloth)
18ebbb5 verified
{
"chat_template": "\n{%- if add_special_tokens -%}\n {{ bos_token }}\n{%- endif -%}\n\n{%- set first_user_prefix = \"\" -%}\n{%- set loop_messages = messages -%}\n{%- for message in loop_messages -%}\n {%- if (message['role'] == 'tool') -%}\n {%- set role = \"user\" -%}\n {%- elif (message['role'] == 'assistant') -%}\n {%- set role = \"model\" -%}\n {%- else -%}\n {%- set role = message['role'] -%}\n {%- endif -%}\n {{ '<start_of_turn>' + role + '\n' + (first_user_prefix if loop.first else \"\") }}\n {%- if (message['role'] == 'tool') -%}\n {{ message['content'] | trim }}\n {%- elif message['content'] is string -%}\n {{ message['content'] | trim }}\n {%- elif message['content'] is iterable -%}\n {%- for item in message['content'] -%}\n {%- if item['type'] == 'image' -%}\n {{ '<start_of_image>' }}\n {%- elif item['type'] == 'text' -%}\n {{ item['text'] | trim }}\n {%- endif -%}\n {%- endfor -%}\n {%- else -%}\n {{ raise_exception(\"Invalid content type\") }}\n {%- endif -%}\n {%- for tool_call in message.tool_calls %}\n {%- if tool_call.function is defined %}\n {%- set tool_call = tool_call.function %}\n {%- endif %}\n {{- '<tool_call>\n{\"name\": \"' }}\n {{- tool_call.name }}\n {{- '\", \"arguments\": ' }}\n {{- tool_call.arguments | tojson }}\n {{- '}\n</tool_call>' }}\n {%- endfor %}\n {{ '<end_of_turn>\n' }}\n{%- endfor -%}\n{%- if add_generation_prompt -%}\n {{'<start_of_turn>model\n'}}\n{%- endif -%}"
}