You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{#- Add default tool system message when tools are provided #}
23
-
{%- setsystem_message = "You are a helpful assistant with tool calling "
24
-
"capabilities. Only reply with a tool call if the function exists in the "
25
-
"library provided by the user. If it doesn't exist, just reply directly in "
26
-
"natural language. When you receive a tool call response, use the output to "
27
-
"format an answer to the original user question."%}
20
+
{%- iftoolsisnotnone%}
21
+
{#- Since not system_message was provided by user, if tool is provided, system_message is now default tool system message #}
22
+
{%- set system_message = "You are a helpful assistant and an expert in function composition. You can answer general questions using your internal knowledge OR invoke functions when necessary. Follow these strict guidelines:\n\n1. FUNCTION CALLS:\n- ONLY use functions that are EXPLICITLY listed in the function list below\n- If NO functions are listed (empty function list []), respond ONLY with internal knowledge or \"I don't have access to [Unavailable service] information\"\n- If a function is not in the list, respond ONLY with internal knowledge or \"I don't have access to [Unavailable service] information\"\n- If ALL required parameters are present AND the query EXACTLY matches a listed function's purpose: output ONLY the function call(s)\n- Use exact format: [func_name1(param1=value1, param2=value2), func_name2(...)]\nExamples:\nCORRECT: [get_weather(location=\"Vancouver\"), calculate_route(start=\"Boston\", end=\"New York\")] <- Only if get_weather and calculate_route are in function list\nINCORRECT: get_weather(location=\"New York\")\nINCORRECT: Let me check the weather: [get_weather(location=\"New York\")]\nINCORRECT: [get_events(location=\"Singapore\")] <- If function not in list\n\n2. RESPONSE RULES:\n- For pure function requests matching a listed function: ONLY output the function call(s)\n- For knowledge questions: ONLY output text\n- For missing parameters: ONLY request the specific missing parameters\n- For unavailable services (not in function list): output ONLY with internal knowledge or \"I don't have access to [Unavailable service] information\". Do NOT execute a function call.\n- If the query asks for information beyond what a listed function provides: output ONLY with internal knowledge about your limitations\n- NEVER combine text and function calls in the same response\n- NEVER suggest alternative functions when the requested service is unavailable\n- NEVER create or invent new functions not listed below\n\n3. STRICT BOUNDARIES:\n- ONLY use functions from the list below - no exceptions\n- NEVER use a function as an alternative to unavailable information\n- NEVER call functions not present in the function list\n- NEVER add explanatory text to function calls\n- NEVER respond with empty brackets\n- Use proper Python/JSON syntax for function calls\n- Check the function list carefully before responding\n\n4. TOOL RESPONSE HANDLING:\n- When receiving tool responses: provide concise, natural language responses\n- Don't repeat tool response verbatim\n- Don't add supplementary information\n\nHere is a list of functions in JSON format that you can invoke:\n" %}
28
23
{%- else%}
29
-
{%- setsystem_message = ""%}
24
+
{%- setsystem_message = ""%}
30
25
{%- endif%}
31
26
{%- endif%}
32
-
33
-
{#- System message if the user supplied one, or if tools are used (default tool system message) #}
27
+
{#- Now writing the system message: use the user provided system message if user_provided_system_message, else default tool system message if tools presented #}
34
28
{%- ifsystem_message%}
35
29
{#- always use user provided system message to override default tool system message #}
36
30
{{- "<|header_start|>system<|header_end|>\n\n" }}
37
31
{{- system_message }}
38
-
{%- iftoolsisnotnoneandnottools_in_user_message%}
39
-
{{- "Tools: You have access to the following tools. You might need to use one "
40
-
"or more function/tool calls to fulfill the task. \n"
41
-
"If none are needed, then proceed to the response.\n\n"
42
-
"Tool Call Syntax: You can call tools using the following syntax:\n"
"Do not include anything else when calling the tools with the syntax above.\n\n"
45
-
"Here is a list of functions in JSON format that you can invoke.\n " }}
46
-
{%- fortintools%}
47
-
{{- t | tojson(indent=4) }}
48
-
{{- "\n\n" }}
49
-
{%- endfor%}
50
-
{%- endif%}
32
+
{%- ifuser_provided_system_messageandtools%}
33
+
{{- "\nHere is a list of functions in JSON format that you can invoke. Use exact format: [func_name1(param1=value1, param2=value2), func_name2(...)]\n" }}
34
+
{{- tool_definition -}}
35
+
{%- eliftool_definition%}
36
+
{{- tool_definition -}}
37
+
{%- endif%}
51
38
{{- "<|eot|>" }}
52
39
{%- endif%}
53
-
54
-
{#- Custom tools are passed in a user message with some extra guidance #}
55
-
{%- iftools_in_user_messageandtoolsisnotnone%}
56
-
{#- Extract the first user message so we can plug it in here #}
0 commit comments