added newline around available tools
Browse files- chat_template_with_tools.jinja +2 -2
- tokenizer_config.json +1 -1
chat_template_with_tools.jinja
CHANGED
|
@@ -9,12 +9,12 @@
|
|
| 9 |
{% if tools is not none and tools|length > 0 %}
|
| 10 |
{%- set tool_str = tools|tojson -%}
|
| 11 |
{%- set tool_instructions =
|
| 12 |
-
'
|
| 13 |
~ '[{"name": "tool1", "parameters": {"p1": "val1" }}, {"name": "tool2", "parameters": {"p2": "val2", "p3": 23}}] '
|
| 14 |
~ ' Your available tools are: '
|
| 15 |
~ '[AVAILABLE_TOOLS]'
|
| 16 |
~ tool_str
|
| 17 |
-
~ '[/AVAILABLE_TOOLS]'
|
| 18 |
-%}
|
| 19 |
{%- set system_message = system_message ~ tool_instructions -%}
|
| 20 |
{% endif %}
|
|
|
|
| 9 |
{% if tools is not none and tools|length > 0 %}
|
| 10 |
{%- set tool_str = tools|tojson -%}
|
| 11 |
{%- set tool_instructions =
|
| 12 |
+
'\nYou can use multiple tools by responding with a JSON array like this: '
|
| 13 |
~ '[{"name": "tool1", "parameters": {"p1": "val1" }}, {"name": "tool2", "parameters": {"p2": "val2", "p3": 23}}] '
|
| 14 |
~ ' Your available tools are: '
|
| 15 |
~ '[AVAILABLE_TOOLS]'
|
| 16 |
~ tool_str
|
| 17 |
+
~ '[/AVAILABLE_TOOLS]\n'
|
| 18 |
-%}
|
| 19 |
{%- set system_message = system_message ~ tool_instructions -%}
|
| 20 |
{% endif %}
|
tokenizer_config.json
CHANGED
|
@@ -9007,7 +9007,7 @@
|
|
| 9007 |
"<SPECIAL_999>"
|
| 9008 |
],
|
| 9009 |
"bos_token": "<s>",
|
| 9010 |
-
"chat_template": "{%- set default_system_message = 'You are AI.' -%}{{ bos_token }}\n{%- if messages[0]['role'] == 'system' %}\n {%- set system_message = messages[0]['content'] %}\n {%- set loop_messages = messages[1:] %}\n{%- else %}\n {%- set system_message = default_system_message %}\n {%- set loop_messages = messages %}\n{%- endif %}\n{% if tools is not none and tools|length > 0 %}\n {%- set tool_str = tools|tojson -%}\n {%- set tool_instructions =\n '
|
| 9011 |
"clean_up_tokenization_spaces": false,
|
| 9012 |
"eos_token": "</s>",
|
| 9013 |
"extra_special_tokens": {},
|
|
|
|
| 9007 |
"<SPECIAL_999>"
|
| 9008 |
],
|
| 9009 |
"bos_token": "<s>",
|
| 9010 |
+
"chat_template": "{%- set default_system_message = 'You are AI.' -%}{{ bos_token }}\n{%- if messages[0]['role'] == 'system' %}\n {%- set system_message = messages[0]['content'] %}\n {%- set loop_messages = messages[1:] %}\n{%- else %}\n {%- set system_message = default_system_message %}\n {%- set loop_messages = messages %}\n{%- endif %}\n{% if tools is not none and tools|length > 0 %}\n {%- set tool_str = tools|tojson -%}\n {%- set tool_instructions =\n '\\nYou can use multiple tools by responding with a JSON array like this: '\n ~ '[{\"name\": \"tool1\", \"parameters\": {\"p1\": \"val1\" }}, {\"name\": \"tool2\", \"parameters\": {\"p2\": \"val2\", \"p3\": 23}}] '\n ~ ' Your available tools are: '\n ~ '[AVAILABLE_TOOLS]'\n ~ tool_str\n ~ '[/AVAILABLE_TOOLS]\\n'\n -%}\n {%- set system_message = system_message ~ tool_instructions -%}\n{% endif %}\n{{- '[SYSTEM_PROMPT]' + system_message + '[/SYSTEM_PROMPT]' }}\n{%- for message in loop_messages %}\n\n {%- if message['role'] == 'user' %}\n {{- '[INST]' + message['content'] + '[/INST]' }}\n\n {%- elif message['role'] == 'system' %}\n {{- '[SYSTEM_PROMPT]' + message['content'] + '[/SYSTEM_PROMPT]' }}\n\n {%- elif message['role'] == 'assistant' %}\n {%- if message.tool_calls is defined and message.tool_calls is not none -%}\n [TOOL_CALLS]\n {{ {\"tool_calls\": message.tool_calls}|tojson }}\n [/TOOL_CALLS]\n {%- elif message['content'] is defined and message['content'] is not none -%}\n {{- message['content'] + eos_token }}\n {%- endif %}\n\n {%- elif message['role'] == 'tool_calls' or message.tool_calls is defined %}\n {%- if message.tool_calls is defined %}\n {%- set tool_calls = message.tool_calls %}\n {%- else %}\n {%- set tool_calls = message.content %}\n {%- endif %}\n {{- \"[TOOL_CALLS] [\" }}\n {%- for tool_call in tool_calls %}\n {%- set out = tool_call.function|tojson %}\n {{- out[:-1] }}\n {%- if not tool_call.id is defined or tool_call.id|length < 9 %}\n {{- raise_exception(\"Tool call IDs should be alphanumeric strings with length >= 9!\" + tool_call.id) }}\n {%- endif %}\n {{- ', \"id\": \"' + tool_call.id + '\"}' }}\n {%- if not loop.last %}\n {{- \", \" }}\n {%- else %}\n {{- \"]\" + eos_token }}\n {%- endif %}\n {%- endfor %}\n\n {%- elif message[\"role\"] == \"tool\" %}\n {%- if message.content is defined and message.content.content is defined %}\n {%- set content = message.content.content %}\n {%- else %}\n {%- set content = message.content %}\n {%- endif %}\n {{- '[TOOL_RESULTS] {\"content\": ' + content|string + \", \" }}\n {%- if not message.tool_call_id is defined or message.tool_call_id|length < 9 %}\n {{- raise_exception(\"Tool call IDs should be alphanumeric strings with length >= 9!\" + message.tool_call_id) }}\n {%- endif %}\n {{- '\"call_id\": \"' + message.tool_call_id + '\"}[/TOOL_RESULTS]' }}\n\n {%- elif message[\"role\"] == \"assistant\" and message.content is defined and message.content is not none %}\n {{- message[\"content\"] + eos_token }}\n\n {%- elif message['role'] == 'tool' -%}\n [TOOL_CONTENT]\n {{ {\"tool_call_id\": message['tool_call_id'], \"tool_call\": message['content']}|tojson }}\n [/TOOL_CONTENT]\n\n {%- else %}\n {{- raise_exception('Only user, system, assistant, tool_call & tool roles are supported!') }}\n {%- endif %}\n{%- endfor %}\n",
|
| 9011 |
"clean_up_tokenization_spaces": false,
|
| 9012 |
"eos_token": "</s>",
|
| 9013 |
"extra_special_tokens": {},
|