55 lines
1.2 KiB
Django/Jinja
55 lines
1.2 KiB
Django/Jinja
{%- if tools %}
|
|
<|im_start|>system
|
|
{%- if messages[0].role == 'system' -%}
|
|
{{ messages[0].content }}
|
|
{%- else -%}
|
|
You are a helpful assistant.
|
|
{%- endif -%}
|
|
|
|
# Tools
|
|
You may call one or more functions to assist with the user query.
|
|
The function signatures are provided below:
|
|
<tools>
|
|
{%- for tool in tools %}
|
|
{{ tool | tojson }}
|
|
{%- endfor %}
|
|
</tools>
|
|
|
|
When you need to call a tool, respond with XML tags in this exact format:
|
|
<tool_call>
|
|
<function=tool_name>
|
|
<parameter=param1>value1</parameter>
|
|
<parameter=param2>value2</parameter>
|
|
</function>
|
|
</tool_call>
|
|
<|im_end|>
|
|
{%- else %}
|
|
{%- if messages[0].role == 'system' -%}
|
|
<|im_start|>system
|
|
{{ messages[0].content }}<|im_end|>
|
|
{%- endif -%}
|
|
{%- endif %}
|
|
|
|
{%- for message in messages %}
|
|
{%- if (message.role == "user") or (message.role == "system" and not loop.first) %}
|
|
<|im_start|>{{ message.role }}
|
|
{{ message.content }}<|im_end|>
|
|
{%- elif message.role == "assistant" %}
|
|
<|im_start|>assistant
|
|
{%- if message.content %}
|
|
{{ message.content }}
|
|
{%- endif %}
|
|
<|im_end|>
|
|
{%- elif message.role == "tool" %}
|
|
<|im_start|>user
|
|
<tool_response>
|
|
{{ message.content }}
|
|
</tool_response>
|
|
<|im_end|>
|
|
{%- endif %}
|
|
{%- endfor %}
|
|
|
|
{%- if add_generation_prompt %}
|
|
<|im_start|>assistant
|
|
{%- endif %}
|