From 1e5bf6c19d7cf65368911c4ee4395e18039424e9 Mon Sep 17 00:00:00 2001 From: ehhuang Date: Sat, 12 Apr 2025 11:54:22 -0700 Subject: [PATCH] feat: update default tool use prompt (#1803) # What does this PR do? User reports in https://github.com/meta-llama/llama-stack/issues/1769#issuecomment-2755564632 that Agent uses tool even on a prompt 'Hello'. Updated the default prompt. Also move the instruction part out of `function_description` so that user can override it if desired. ## Test Plan image Also performance on 100 hotpotqa questions are similar to the current prompt. --- .../llama/llama3/prompt_templates/system_prompts.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/llama_stack/models/llama/llama3/prompt_templates/system_prompts.py b/llama_stack/models/llama/llama3/prompt_templates/system_prompts.py index d4e825a22..fbc0127fd 100644 --- a/llama_stack/models/llama/llama3/prompt_templates/system_prompts.py +++ b/llama_stack/models/llama/llama3/prompt_templates/system_prompts.py @@ -229,6 +229,11 @@ class PythonListCustomToolGenerator(PromptTemplateGeneratorBase): # noqa: N801 You are an expert in composing functions. You are given a question and a set of possible functions. Based on the question, you may or may not need to make one function/tool call to achieve the purpose. + If you decide to invoke any of the function(s), you MUST put it in the format of [func_name1(params_name1=params_value1, params_name2=params_value2...), func_name2(params)] + If you decide to invoke a function, you SHOULD NOT include any other text in the response. besides the function call in the above format. + For a boolean parameter, be sure to use `True` or `False` (capitalized) for the value. + + {{ function_description }} """.strip("\n") ) @@ -243,10 +248,6 @@ class PythonListCustomToolGenerator(PromptTemplateGeneratorBase): # noqa: N801 def _gen_function_description(self, custom_tools: List[ToolDefinition]) -> PromptTemplate: template_str = textwrap.dedent( """ - If you decide to invoke any of the function(s), you MUST put it in the format of [func_name1(params_name1=params_value1, params_name2=params_value2...), func_name2(params)] - For a boolean parameter, be sure to use `True` or `False` (capitalized) for the value. - You SHOULD NOT include any other text in the response. - Here is a list of functions in JSON format that you can invoke. [