Declare the system prompt chunks used for different features
*/}}
{{- $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>" }}
{{- $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." }}
{{- $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>" }}
{{- $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." }}
{{- /*
Declare the prompt structure variables to be filled in from messages
*/}}
{{- $tools_system_message := "" }}
{{- $documents_system_message := "" }}
{{- $system_message := "" }}
{{- $document_counter := 0 }}
{{- $last_query_index := 0 }}
{{- /*
Output parsing heuristic
Ollama has very specific heuristics for parsing the tags for thinking and tool
calling. Rather than contorting the actual message expansion to match the
expectations, we explicitly put them here behind an unreachable condition.