char-fork/llama.cpp
git clone https://git.t4t.associates/char-fork/llama.cpp
bb771cbd2
char/aliceai-t5-moe
1{%- set tools_system_message_prefix = 'You are a helpful assistant with access to the following tools. You may call one or more tools to assist with the user query.\n\nYou are provided with function signatures within <tools></tools> XML tags:\n<tools>' %} 2{%- set tools_system_message_suffix = '\n</tools>\n\nFor each tool call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\n<tool_call>\n{\" name \ ": <function-name>, \" arguments \ ": <args-json-object>}\n</tool_call>. If a tool does not exist in the provided list of tools, notify the user that you do not have the ability to fulfill the request.' %} 3{%- set documents_system_message_prefix = 'You are a helpful assistant with access to the following documents. You may use one or more documents to assist with the user query.\n\nYou are given a list of documents within <documents></documents> XML tags:\n<documents>' %} 4{%- set documents_system_message_suffix = '\n</documents>\n\nWrite the response to the user\' s input by strictly aligning with the facts in the provided documents . If the information needed to answer the question is not available in the documents , inform the user that the question cannot be answered based on the available data . ' %} 5{%- if available_tools is defined and available_tools %} 6{%- set tools = available_tools %} 7{%- endif %} 8{%- set ns = namespace(tools_system_message=tools_system_message_prefix, 9documents_system_message=documents_system_message_prefix, 10system_message='' 11) %} 12{%- if tools %} 13{%- for tool in tools %} 14{%- set ns.tools_system_message = ns.tools_system_message + ' \ n ' + (tool | tojson) %} 15{%- endfor %} 16{%- set ns.tools_system_message = ns.tools_system_message + tools_system_message_suffix %} 17{%- else %} 18{%- set ns.tools_system_message = '' %} 19{%- endif %} 20{%- if documents %} 21{%- for document in documents %} 22{%- set ns.documents_system_message = ns.documents_system_message + ' \ n ' + (document | tojson) %} 23{%- endfor %} 24{%- set ns.documents_system_message = ns.documents_system_message + documents_system_message_suffix %} 25{%- else %} 26{%- set ns.documents_system_message = '' %} 27{%- endif %} 28{%- if messages[0].role == ' system ' %} 29{%- if messages[0].content is string %} 30{%- set ns.system_message = messages[0].content %} 31{%- elif messages[0].content is iterable %} 32{%- for entry in messages[0].content %} 33{%- if entry.type== ' text ' %} 34{%- if ns.system_message != '' %} 35{%- set ns.system_message = ns.system_message + ' \ n ' %} 36{%- endif %} 37{%- set ns.system_message = ns.system_message + entry.text %} 38{%- endif %} 39{%- endfor %} 40{%- endif %} 41{%- if tools and documents %} 42{%- set ns.system_message = ns.system_message + ' \ n \ n ' + ns.tools_system_message + ' \ n \ n ' + ns.documents_system_message %} 43{%- elif tools %} 44{%- set ns.system_message = ns.system_message + ' \ n \ n ' + ns.tools_system_message %} 45{%- elif documents %} 46{%- set ns.system_message = ns.system_message + ' \ n \ n ' + ns.documents_system_message %} 47{%- endif %} 48{%- else %} 49{%- if tools and documents %} 50{%- set ns.system_message = ns.tools_system_message + ' \ n \ n ' + ns.documents_system_message %} 51{%- elif tools %} 52{%- set ns.system_message = ns.tools_system_message %} 53{%- elif documents %} 54{%- set ns.system_message = ns.documents_system_message %} 55{%- endif %} 56{%- endif %} 57{%- if ns.system_message %} 58{{- ' <| start_of_role |> system <| end_of_role |> ' + ns.system_message + ' <| end_of_text |>\ n ' }} 59{%- endif %} 60{%- for message in messages %} 61{%- set content = namespace(val='') %} 62{%- if message.content is string %} 63{%- set content.val = message.content %} 64{%- else %} 65{%- if message.content is iterable %} 66{%- for entry in message.content %} 67{%- if entry.type== ' text ' %} 68{%- if content.val != '' %} 69{%- set content.val = content.val + ' \ n ' %} 70{%- endif %} 71{%- set content.val = content.val + entry.text %} 72{%- endif %} 73{%- endfor %} 74{%- endif %} 75{%- endif %} 76{%- if (message.role == ' user ') or (message.role == ' system ' and not loop.first) %} 77{{- ' <| start_of_role |> ' + message.role + ' <| end_of_role |> ' + content.val + ' <| end_of_text |>\ n ' }} 78{%- elif message.role == ' assistant ' %} 79{{- ' <| start_of_role |> ' + message.role + ' <| end_of_role |> ' + content.val }} 80{%- if message.tool_calls %} 81{%- for tool_call in message.tool_calls %} 82{%- if (loop.first and content.val) or (not loop.first) %} 83{{- ' \ n ' }} 84{%- endif %} 85{%- if tool_call.function %} 86{%- set tool_call = tool_call.function %} 87{%- endif %} 88{{- ' < tool_call >\ n{ "name" : "' }} 89{{ - tool_call . name }} 90{{ - '" , "arguments" : ' }} 91{%- if tool_call.arguments is string %} 92{{- tool_call.arguments }} 93{%- else %} 94{{- tool_call.arguments | tojson }} 95{%- endif %} 96{{- ' } \ n </ tool_call > ' }} 97{%- endfor %} 98{%- endif %} 99{{- ' <| end_of_text |>\ n ' }} 100{%- elif message.role == ' tool ' %} 101{%- if loop.first or (messages[loop.index0 - 1].role != ' tool ') %} 102{{- ' <| start_of_role |> user <| end_of_role |> ' }} 103{%- endif %} 104{{- ' \ n < tool_response >\ n ' }} 105{{- content.val }} 106{{- ' \ n </ tool_response > ' }} 107{%- if loop.last or (messages[loop.index0 + 1].role != ' tool ') %} 108{{- ' <| end_of_text |>\ n ' }} 109{%- endif %} 110{%- endif %} 111{%- endfor %} 112{%- if add_generation_prompt %} 113{{- ' <| start_of_role |> assistant <| end_of_role |> ' }} 114{% - endif %}