char-fork/llama.cpp
git clone https://git.t4t.associates/char-fork/llama.cpp
16d222fc5
char/aliceai-t5-moe
1{{ '<begin_of_document>' - }} 2{%- if custom_tools is defined %} 3{%- set tools = custom_tools %} 4{%- endif %} 5{%- if not tools is defined %} 6{%- set tools = none %} 7{%- endif %} 8 9{#- Extract system message #} 10{% set ns = namespace ( system_prompt = '' ) - %} 11{%- if messages [ 0 ][ 'role' ] == 'system' %} 12{%- if messages [ 0 ][ 'content' ] is string %} 13{%- set ns . system_prompt = messages [ 0 ][ 'content' ]| trim %} 14{%- else %} 15{%- set ns . system_prompt = messages [ 0 ][ 'content' ][ 0 ][ 'text' ]| trim %} 16{%- endif %} 17{%- set messages = messages [ 1 :] %} 18{%- else %} 19{%- if tools is not none %} 20{%- set ns . system_prompt = "You are a helpful assistant created by Minimax based on MiniMax-M1 model." %} 21{%- else %} 22{%- set ns . system_prompt = "You are a helpful assistant created by Minimax based on MiniMax-M1 model." %} 23{%- endif %} 24{%- endif %} 25 26{#- System message #} 27{%- if ns . system_prompt != '' %} 28{{ '<beginning_of_sentence>system ai_setting=assistant\n' + ns . system_prompt + '<end_of_sentence>\n' - }} 29{%- endif %} 30 31{#- Tools configuration #} 32{%- if tools is not none %} 33{{ '<beginning_of_sentence>system tool_setting=tools\nYou are provided with these tools:\n<tools>\n' - }} 34{%- for tool in tools %} 35{{ tool | tojson ~ '\n' - }} 36{%- endfor %} 37{{ '</tools>\n\nIf you need to call tools, please respond with <tool_calls></tool_calls> XML tags, and provide tool-name and json-object of arguments, following the format below:\n<tool_calls>\n{" name ": <tool-name>, " arguments ": <args-json-object>}\n...\n</tool_calls><end_of_sentence>\n' - }} 38{%- endif %} 39 40{#- Process messages #} 41{%- for message in messages %} 42{%- if not ( message . role == 'ipython' or message . role == 'tool' or 'tool_calls' in message ) %} 43{%- if message [ 'role' ] == 'user' %} 44{{ '<beginning_of_sentence>user name=user\n' - }} 45{%- if message [ 'content' ] is string %} 46{{ message [ 'content' ]| trim - }} 47{%- else %} 48{%- for content in message [ 'content' ] %} 49{%- if content [ 'type' ] == 'text' %} 50{{ content [ 'text' ]| trim - }} 51{%- endif %} 52{%- endfor %} 53{%- endif %} 54{{ '<end_of_sentence>\n' - }} 55{%- elif message [ 'role' ] == 'assistant' %} 56{{ '<beginning_of_sentence>ai name=assistant\n' - }} 57{%- if message [ 'content' ] is string %} 58{{ message [ 'content' ]| trim - }} 59{%- else %} 60{%- for content in message [ 'content' ] | selectattr ( 'type' , 'equalto' , 'text' ) %} 61{{ content [ 'text' ]| trim - }} 62{%- endfor %} 63{%- endif %} 64{{ '<end_of_sentence>\n' - }} 65{%- endif %} 66{%- elif 'tool_calls' in message %} 67{{ '<beginning_of_sentence>ai name=assistant\n<tool_calls>\n' - }} 68{%- for tool_call in message . tool_calls %} 69{{ '{" name ": "' + tool_call.function.name + '", " arguments ": ' + tool_call . function . arguments | tojson + '}\n' - }} 70{%- endfor %} 71{{ '</tool_calls><end_of_sentence>\n' - }} 72{%- elif message . role == "tool" or message . role == "ipython" %} 73{{ '<beginning_of_sentence>tool name=tools\n' - }} 74{%- if message . content is string %} 75{{ 'tool result: ' + message . content + '\n\n' - }} 76{%- else %} 77{%- for content in message [ 'content' ] %} 78{%- if content [ 'type' ] == 'text' %} 79{{ 'tool result: ' + content [ 'text' ] + '\n\n' - }} 80{%- elif content . get ( 'name' ) %} 81{{ 'tool name: ' + content [ 'name' ] + '\ntool result: ' + content [ 'text' ] + '\n\n' - }} 82{%- endif %} 83{%- endfor %} 84{%- endif %} 85{{ '<end_of_sentence>\n' - }} 86{%- endif %} 87{%- endfor %} 88 89{%- if add_generation_prompt %} 90{{ '<beginning_of_sentence>ai name=assistant\n' - }} 91{%- endif %}