pittawat's picture
Add files using upload-large-folder tool
9b505b2 verified
{%- if tools %}
{{- '<|im_start|>system\n' }}
{%- if messages[0]['role'] == 'system' %}
{{- messages[0]['content'] }}
{%- else %}
{{- 'You are Typhoon, created by SCB 10X. You are a helpful assistant.' }}
{%- endif %}
{{- "\n" }}
{{- "You are given a question and a set of possible functions. Based on the question, you will need to make one or more function/tool calls to achieve the purpose." }}
{{- "If none of the function can be used, point it out. If the given question lacks the parameters required by the function, also point it out." }}
{{- "You should only return the function call in tools call sections." }}
{{- "If you decide to invoke any of the function(s), you MUST put it in the format of [Function(arguments1={{params_name1: params_value1,params_name2: params_value2, ...}}, name1=function_name1), Function(arguments2={{params}}, name2=function_name2) , ...]"}}
{{- "You SHOULD NOT include any other text in the response.\nHere is a list of functions in JSON format that you can invoke.\n" }}
{%- for t in tools %}
{{- t | tojson(indent=4) }}
{{- "\n\n" }}
{%- endfor %}
{%- else %}
{%- if messages[0]['role'] == 'system' %}
{{- '<|im_start|>system\n' + messages[0]['content'] + '<|im_end|>\n' }}
{%- else %}
{{- '<|im_start|>system\nYou are Typhoon, created by SCB 10X. You are a helpful assistant. Typhoon follows this information in all languages, and always responds to the user in the language they use or request.<|im_end|>\n' }}
{%- endif %}
{%- endif %}
{%- for message in messages %}
{%- if (message.role == "user") or (message.role == "system" and not loop.first) or (message.role == "assistant" and not message.tool_calls) %}
{{- '<|im_start|>' + message.role + '\n' + message.content + '<|im_end|>' + '\n' }}
{%- elif message.role == "assistant" %}
{{- '<|im_start|>' + message.role }}
{%- if message.content %}
{{- '\n' + message.content }}
{%- endif %}
{{- '<|im_end|>\n' }}
{%- elif message.role == "tool" %}
{{- '<|im_start|>' + message.role }}
{%- if message.content is mapping or message.content is iterable %}
{{- message.content | tojson }}
{%- else %}
{{- message.content }}
{%- endif %}
{{- '<|im_end|>\n' }}
{%- endif %}
{%- endfor %}
{%- if add_generation_prompt %}
{{- '<|im_start|>assistant\n' }}
{%- endif %}