# Question about Function Calling & JSON mode

**URL:** <https://community.openai.com/t/question-about-function-calling-json-mode/562940>\
**Category:** API\
**Tags:** api, function-calling, json-mode\
**Created:** [December 18, 2023, 7:13am UTC](https://community.openai.com/t/question-about-function-calling-json-mode/562940 "2023-12-18T07:13:44Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![\_j](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/_j/32/766292_2.png) [@\_j](https://community.openai.com/u/_j)\
**Post date:** [December 19, 2023, 10:06am UTC](https://community.openai.com/t/question-about-function-calling-json-mode/562940/5 "2023-12-19T10:06:20Z")

</div>

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:

> [@Bad results when using fine-tuned model with function calling](https://community.openai.com/t/bad-results-when-using-fine-tuned-model-with-function-calling/428832/8):
>
> Hey folks. I’m about to show how to properly insert your function return back to the AI - something far too useful for OpenAI to document properly. chat\_completion\_parameters = { "model": "gpt-3.5-turbo", "top\_p": 0.5, "messages": [ {"role": "system", "content": "You are MegaBot, my fine-tune AI identity."}, # chat history goes here {"role": "user", "content": "Who won the 2024 election?"}, {"role": "assistant", "content": assistant\_content\_if\_exist, "function\_call": { "name": called\_functi…

---

_[View the full topic](https://community.openai.com/t/question-about-function-calling-json-mode/562940)._
