From bf45cecf783efb4da0275b0ba40a2bcfc9387068 Mon Sep 17 00:00:00 2001 From: nguyenhoangthuan99 Date: Tue, 29 Oct 2024 18:19:19 +0700 Subject: [PATCH 1/2] Update function calling prompt --- engine/utils/function_calling/llama3.1.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/engine/utils/function_calling/llama3.1.h b/engine/utils/function_calling/llama3.1.h index 5c2e6ffdb..a0ebe941e 100644 --- a/engine/utils/function_calling/llama3.1.h +++ b/engine/utils/function_calling/llama3.1.h @@ -30,14 +30,15 @@ Here is an example, Reminder: - Function calls MUST follow the specified format - Required parameters MUST be specified -- Only call one function at a time +- You can call one or more functions at a time - Put the entire function call reply on one line - Always add your sources when using search results to answer the user query -- If can not find correct parameters corresponding to function, ask user again to provide. +- If you can not find correct parameters or arguments corresponding to function in the user's message, ask user again to provide, do not make assumptions. - No explanation are needed when calling a function. You are a helpful assistant. )"; -constexpr auto tool_role = "<|eot_id|>\n<|start_header_id|>ipython<|end_header_id|>\n"; +constexpr auto tool_role = + "<|eot_id|>\n<|start_header_id|>ipython<|end_header_id|>\n"; } // namespace function_calling_llama3_1_utils From 643cb47d1ce2ebab81225685d98be4e67fee9263 Mon Sep 17 00:00:00 2001 From: nguyenhoangthuan99 Date: Tue, 29 Oct 2024 20:03:32 +0700 Subject: [PATCH 2/2] Update prompt --- engine/utils/function_calling/common.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/engine/utils/function_calling/common.h b/engine/utils/function_calling/common.h index d01f22423..eb0d45cf4 100644 --- a/engine/utils/function_calling/common.h +++ b/engine/utils/function_calling/common.h @@ -158,6 +158,10 @@ inline void UpdateMessages(std::string& system_prompt, tool_choice["function"]["name"].asString() + "' to answer the user's question."; } + bool parallel_tool_calls = request->get("parallel_tool_calls", true).asBool(); + if (!parallel_tool_calls) { + system_prompt += "\n\nNow this is your first priority: You must call the only one function at a time."; + } bool tools_call_in_user_message = request->get("tools_call_in_user_message", false).asBool();