File size: 4,564 Bytes
25bd235
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
{
  "additional_special_tokens": null,
  "backend": "tokenizers",
  "bos_token": "<|startoftext|>",
  "clean_up_tokenization_spaces": false,
  "eos_token": "<|im_end|>",
  "is_local": true,
  "legacy": false,
  "model_input_names": [
    "input_ids",
    "attention_mask"
  ],
  "model_max_length": 1000000000000000019884624838656,
  "model_specific_special_tokens": {},
  "pad_token": "<|pad|>",
  "sp_model_kwargs": {},
  "spaces_between_special_tokens": false,
  "tokenizer_class": "TokenizersBackend",
  "use_default_system_prompt": false,
  "use_fast": true,
  "chat_template": "{{- bos_token -}}\n{%- set keep_past_thinking = keep_past_thinking | default(false) -%}\n{%- set ns = namespace(system_prompt=\"\") -%}\n{%- if messages[0][\"role\"] == \"system\" -%}\n    {%- set ns.system_prompt = messages[0][\"content\"] -%}\n    {%- set messages = messages[1:] -%}\n{%- endif -%}\n{%- if tools -%}\n    {%- set ns.system_prompt = ns.system_prompt + (\"\\n\" if ns.system_prompt else \"\") + \"List of tools: [\" -%}\n    {%- for tool in tools -%}\n        {%- if tool is not string -%}\n            {%- set tool = tool | tojson -%}\n        {%- endif -%}\n        {%- set ns.system_prompt = ns.system_prompt + tool -%}\n        {%- if not loop.last -%}\n            {%- set ns.system_prompt = ns.system_prompt + \", \" -%}\n        {%- endif -%}\n    {%- endfor -%}\n    {%- set ns.system_prompt = ns.system_prompt + \"]\" -%}\n{%- endif -%}\n{%- if ns.system_prompt -%}\n    {{- \"<|im_start|>system\\n\" + ns.system_prompt + \"<|im_end|>\\n\" -}}\n{%- endif -%}\n{%- set ns.last_assistant_index = -1 -%}\n{%- for message in messages -%}\n    {%- if message[\"role\"] == \"assistant\" -%}\n        {%- set ns.last_assistant_index = loop.index0 -%}\n    {%- endif -%}\n{%- endfor -%}\n{%- for message in messages -%}\n    {{- \"<|im_start|>\" + message[\"role\"] + \"\\n\" -}}\n    {%- if message.get('tool_calls') %}\n        {# \u2500\u2500\u2500\u2500\u2500 create a list to append tool calls to \u2500\u2500\u2500\u2500\u2500 #}\n        {%- set tool_calls_ns = namespace(tool_calls=[])%}\n        {%- for tool_call in message['tool_calls'] %}\n            {%- set func_name = tool_call['function']['name'] %}\n            {%- set func_args = tool_call['function']['arguments'] %}\n            {# \u2500\u2500\u2500\u2500\u2500 create a list of func_arg strings to accumulate for each tool call \u2500\u2500\u2500\u2500\u2500 #}\n            {%- set args_ns = namespace(arg_strings=[])%}\n            {%- for arg_name, arg_value in func_args.items() %}\n                {%- if arg_value is none %}\n                    {%- set formatted_arg_value = 'null' %}\n                {%- elif arg_value is boolean %}\n                    {%- set formatted_arg_value = 'True' if arg_value else 'False' %}\n                {%- elif arg_value is string %}\n                    {%- set formatted_arg_value = '\"' ~ arg_value ~ '\"' %}\n                {%- elif arg_value is mapping or arg_value is iterable %}\n                    {%- set formatted_arg_value = arg_value | tojson %}\n                {%- else %}\n                    {%- set formatted_arg_value = arg_value | string %}\n                {%- endif %}\n                {# \u2500\u2500\u2500\u2500\u2500 format each argument key,value pair \u2500\u2500\u2500\u2500\u2500 #}\n                {%- set args_ns.arg_strings =  args_ns.arg_strings + [arg_name ~ '=' ~ formatted_arg_value] %}\n            {%- endfor %}\n            {# \u2500\u2500\u2500\u2500\u2500 append each formatted tool call \u2500\u2500\u2500\u2500\u2500 #}\n            {%- set tool_calls_ns.tool_calls = tool_calls_ns.tool_calls + [(func_name + '(' + (args_ns.arg_strings | join(\", \")) + ')' )]%}\n        {%- endfor %}\n        {# \u2500\u2500\u2500\u2500\u2500 format the final tool calls \u2500\u2500\u2500\u2500\u2500 #}\n        {{-'<|tool_call_start|>[' + (tool_calls_ns.tool_calls | join(\", \")) + ']<|tool_call_end|>'}}\n    {%- endif %}\n    {%- set content = message[\"content\"] -%}\n    {%- if content is not string -%}\n        {%- set content = content | tojson -%}\n    {%- endif -%}\n    {%- if message[\"role\"] == \"assistant\" and not keep_past_thinking and loop.index0 != ns.last_assistant_index -%}\n        {%- if \"</think>\" in content -%}\n            {%- set content = content.split(\"</think>\")[-1] | trim -%}\n        {%- endif -%}\n    {%- endif -%}\n    {{- content + \"<|im_end|>\\n\" -}}\n{%- endfor -%}\n{%- if add_generation_prompt -%}\n    {{- \"<|im_start|>assistant\\n\" -}}\n{%- endif -%}\n"
}