@@ -4151,28 +4151,20 @@ def gguf_function_calling(
41514151 "<|im_start|>{{ message.role }}\n "
41524152 # System message
41534153 "{% if message.role == 'system' %}"
4154- "<|system|>\n "
41554154 "{{ message.content }}"
4156- "{% if tools %}"
4157- "\n # Tools\n "
4158- "\n You may call one or more functions to assist with the user query."
4159- "\n Prefer proposing the function first; only emit `<function_calls>` when user intent to run is clear from context."
4160- "\n \n Soft consent policy:"
4161- "\n - Proceed immediately if the user explicitly asks to run/fetch/call/use a tool, or previously agreed, or supplied all required parameters."
4162- "\n - Otherwise: reply with a one-line proposal naming the function and why, and end with “Proceed?”."
4163- "\n - Do not over-ask if consent is obvious."
4164- "\n \n You are provided with function signatures within <tools></tools> XML tags:"
4165- "\n <tools>"
4155+ "{% if tool_calls %}"
4156+ "\n \n You have access to the following functions:\n "
41664157 "{% for tool in tools %}"
4167- "{{ tool | tojson }}"
4168- "{% endfor %}"
4169- "</tools>"
4170- "\n \n You can respond in two ways:"
4171- "\n \n 1. Message only (proposal/confirmation step):"
4172- "\n message:"
4173- "\n I can use `ExampleFunction` to retrieve that. Proceed?"
4174- "\n \n 2. Message + function calls (when intent is clearly allowed by context):"
4175- "\n message:"
4158+ '\n {% if tool.function.get("description") %}/* {{ tool.function.description | trim }} */{% endif %}'
4159+ "\n functions.{{ tool.function.name }}:\n "
4160+ "{{ tool.function.parameters | tojson }}"
4161+ "\n {% endfor %}"
4162+ "\n You must respond to user messages with either a single message or with one or more function calls."
4163+ "\n \n To respond with a message use the following format:"
4164+ "\n \n message:"
4165+ "\n <message>"
4166+ "\n \n To respond with one or more function calls use the following format:"
4167+ "\n \n <function_calls>"
41764168 "\n functions.<function_name>:"
41774169 '\n { "arg1": "value1", "arg2": "value2" }'
41784170 "\n functions.<function_name>:"
@@ -4208,14 +4200,10 @@ def gguf_function_calling(
42084200 "{% endfor %}"
42094201 "{% if add_generation_prompt %}<|im_start|>assistant\n {% endif %}"
42104202 )
4211-
42124203 if hasattr (llama , 'model_path' ):
42134204 metadata = llama .metadata
42144205 if metadata and "tokenizer.chat_template" in metadata :
42154206 function_calling_template = metadata ["tokenizer.chat_template" ]
4216-
4217- if kwargs .get ('chat_template' ):
4218- function_calling_template = kwargs .get ('chat_template' )
42194207
42204208 template_renderer = ImmutableSandboxedEnvironment (
42214209 autoescape = jinja2 .select_autoescape (["html" , "xml" ]),
0 commit comments