Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.

Commit 46caedf

Browse files
Feat/function calling (#1572)
* Update function calling prompt * Update prompt
1 parent 3e04350 commit 46caedf

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

engine/utils/function_calling/common.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,10 @@ inline void UpdateMessages(std::string& system_prompt,
157157
tool_choice["function"]["name"].asString() +
158158
"' to answer the user's question.";
159159
}
160+
bool parallel_tool_calls = request->get("parallel_tool_calls", true).asBool();
161+
if (!parallel_tool_calls) {
162+
system_prompt += "\n\nNow this is your first priority: You must call the only one function at a time.";
163+
}
160164

161165
bool tools_call_in_user_message =
162166
request->get("tools_call_in_user_message", false).asBool();

engine/utils/function_calling/llama3.1.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,15 @@ Here is an example,
3030
Reminder:
3131
- Function calls MUST follow the specified format
3232
- Required parameters MUST be specified
33-
- Only call one function at a time
33+
- You can call one or more functions at a time
3434
- Put the entire function call reply on one line
3535
- Always add your sources when using search results to answer the user query
36-
- If can not find correct parameters corresponding to function, ask user again to provide.
36+
- 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.
3737
- No explanation are needed when calling a function.
3838
3939
You are a helpful assistant.
4040
)";
4141

42-
constexpr auto tool_role = "<|eot_id|>\n<|start_header_id|>ipython<|end_header_id|>\n";
42+
constexpr auto tool_role =
43+
"<|eot_id|>\n<|start_header_id|>ipython<|end_header_id|>\n";
4344
} // namespace function_calling_llama3_1_utils

0 commit comments

Comments
 (0)