char-fork/llama.cpp
git clone https://git.t4t.associates/char-fork/llama.cpp
1d6d4cf7a
char/aliceai-t5-moe
1{{ - bos_token - }} 2{%- set keep_past_thinking = keep_past_thinking | default ( false ) - %} 3{%- set ns = namespace ( system_prompt = "" ) - %} 4{%- if messages [ 0 ][ "role" ] == "system" -%} 5{%- set ns . system_prompt = messages [ 0 ][ "content" ] - %} 6{%- set messages = messages [ 1 :] - %} 7{%- endif -%} 8{%- if tools -%} 9{%- set ns . system_prompt = ns . system_prompt + ( "\n" if ns . system_prompt else "" ) + "List of tools: [" -%} 10{%- for tool in tools -%} 11{%- if tool is not string -%} 12{%- set tool = tool | tojson -%} 13{%- endif -%} 14{%- set ns . system_prompt = ns . system_prompt + tool -%} 15{%- if not loop . last -%} 16{%- set ns . system_prompt = ns . system_prompt + ", " -%} 17{%- endif -%} 18{%- endfor -%} 19{%- set ns . system_prompt = ns . system_prompt + "]" -%} 20{%- endif -%} 21{%- if ns . system_prompt -%} 22{{ - "<|im_start|>system\n" + ns . system_prompt + "<|im_end|>\n" - }} 23{%- endif -%} 24{%- set ns . last_assistant_index = - 1 -%} 25{%- for message in messages -%} 26{%- if message [ "role" ] == "assistant" -%} 27{%- set ns . last_assistant_index = loop . index0 -%} 28{%- endif -%} 29{%- endfor -%} 30{%- for message in messages -%} 31{{ - "<|im_start|>" + message [ "role" ] + "\n" - }} 32{%- set content = message [ "content" ] - %} 33{%- if content is not string -%} 34{%- set content = content | tojson -%} 35{%- endif -%} 36{%- if message [ "role" ] == "assistant" and not keep_past_thinking and loop . index0 != ns . last_assistant_index -%} 37{%- if "</think>" in content -%} 38{%- set content = content . split ( "</think>" )[- 1 ] | trim -%} 39{%- endif -%} 40{%- endif -%} 41{{ - content + "<|im_end|>\n" - }} 42{%- endfor -%} 43{%- if add_generation_prompt -%} 44{{ - "<|im_start|>assistant\n" - }} 45{%- endif -%}