#Conditional function calls
1 messages · Page 1 of 1 (latest)
Hi @sly abyss. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
Yes, you can certainly implement a chain of thoughts approach and split system prompts for function calls, especially if the function calls are dependent on each other. This approach is in line with the concept of "prompt chaining" or "chain-of-thought prompting" where complex tasks are broken down into smaller tasks, improving reliability and performance source (https://cookbook.openai.com/articles/techniques_to_improve_reliability#extensions-to-chain-of-thought-prompting).
When it comes to function calling, OpenAI recommends including instructions regarding when to call a function in the system prompt, while using the function definition to provide instructions on how to call the function and how to generate the parameters source (https://platform.openai.com/docs/guides/function-calling).
For example, if you have a drone AI co-pilot that can perform various actions, you can define a system prompt for the co-pilot and then define functions for all of the actions the co-pilot can take source (https://cookbook.openai.com/examples/fine_tuning_for_function_calling#baseline-testing).
DRONE_SYSTEM_PROMPT = """You are an intelligent AI that controls a drone. Given a command or request from the user,
call one of your functions to complete the request. If the request cannot be completed by your available functions, call the reject_request function.
If the request is ambiguous or unclear, reject the request."""
function_list = [
{
"type": "function",
"function": {
"name": "takeoff_drone",
"description": "Initiate the drone's takeoff sequence.",
"parameters": {
"type": "object",
"properties": {
"altitude": {
"type": "integer",
"description": "Specifies the altitude in meters to which the drone should ascend.",
}
},
"required": ["altitude"],
},
},
},
# Other functions...
]
In this example, the system prompt instructs the AI on when to call a function (i.e., when a command or request is given by the user), and the function definitions provide instructions on how to call the function and generate the parameters.
If you have a complex task that requires multiple function calls, you can break it down into smaller tasks and use separate system prompts for each function call. This approach can help improve the reliability and performance of your AI system.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------