Question about Function Calling & JSON mode

There’s several things here:

  • If the AI calls a function, there is generally no “content”, thus you get an error when trying to parse content with an empty value. That is the error seen in the first message: parsing the response object.

  • Individual API calls have no memory between them. You must construct a history of user and assistant exchanges and pass as much of that back to the model as you would need for following a conversation.

  • Function calls likewise need their own conversation history, which is inserted after the most recent user input. They are the assistant and function return messages that tell the AI what it requested and what was received back. Then in that second call, the AI can use the information to either answer the user or continue calling functions.

This post shows how to insert the last two when using functions: