Force gpt-3.5-turbo-0613 to only return functions

I have a use case where I only want gpt-3.5-turbo to always return one of the defined functions (functionA, functionB, functionC) and never return anything but a function.

"function_call": {"name": "function_name"} param allows you to force it to select one function, but is there any way for it to be forced to return one of several functions?

The perfect solution would be for this to be possible to specify in the function_call itself even though this is not possible at the moment i.e.

"function_call": {"name": ["functionA", "functionB", "functionC"]}"

Putting this requirement into the system message seems to work for gpt-4, but curious if there is a way to do this for gpt-3.5 :thinking:


I want exactly what you are looking for, have you find the solution ?

3 ideas that might help:

  1. Aside for instructing it to do so, prepend a 1-shot example of how it must respond.
  2. Check the response received to confirm it has done so, before continuing on with your script. (If it hasn’t done what you asked, maybe resend?)
  3. Maybe lowering the temperature.

Very similar issue in this thread.

TLDR: You can make two API Calls, one to determine which function to call, using a function that takes only one argument that is an enum of function names and a second one using the function_call parameter with the value returned in the previous call.

The detailed explanation can be found here: