Skip to content

Commit

Permalink
Feat/function calling (#1572)
Browse files Browse the repository at this point in the history
* Update function calling prompt

* Update prompt
  • Loading branch information
nguyenhoangthuan99 authored Nov 5, 2024
1 parent 3e04350 commit 46caedf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 4 additions & 0 deletions engine/utils/function_calling/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,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();
Expand Down
7 changes: 4 additions & 3 deletions engine/utils/function_calling/llama3.1.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 46caedf

Please sign in to comment.