Couple issues with function calling guide

The function calling guide reads as follows:

The basic sequence of steps for function calling is as follows:

  1. Call the model with the user query and a set of functions defined in the functions parameter.
  2. 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).
  3. Parse the string into JSON in your code, and call your function with the provided arguments if they exist.
  4. 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.

Agree on point a) disagree on point b). For b), you can send anything you like, you can send a string with “function was called OK here” or you can include just the function results or whatever you like.

The response is simply text with some symbology that the model will take into account but does not detract from the meaning.

That’s a fair point. Although, the examples I’ve seen from OpenAI even on this page do seem to include both messages, and since this page is under Guides and not API Reference I think some elucidation here would be appropriate.

1 Like