The function calling guide reads as follows:
The basic sequence of steps for function calling is as follows:
- Call the model with the user query and a set of functions defined in the functions parameter.
- The model can choose to call a function; if so, the content will be a stringified JSON object adhering to your custom schema (note: the model may generate invalid JSON or hallucinate parameters).
- Parse the string into JSON in your code, and call your function with the provided arguments if they exist.
- Call the model again by appending the function response as a new message, and let the model summarize the results back to the user.
I see two issues with this:
a. In step 2., the phrase “if so, the content will be a stringified JSON object” doesn’t appear to be correct. From what I see, the content property will be “null”, and the stringified JSON object will appear in a property called “function_call”.
b. Step 4. says to call the model again by appending the function response. However, it does not mention that before appending the function response, you should append the prior model response message that specified the function call to be made.