Another possibility is to divide the task into two different API calls:
- The first determines the function to call
- The second one has the name of the function from the previous step in the function_call parameter.
For the first request I created a select_action function that takes an enum argument with the names of the functions.
I created a Medium post called “How to force GPT models to always use functions” with more details.