Amazed by Function Calling API

I’m experimenting with function calling and encountered something quite unexpected.

Per the API, I provided a list of the available functions to ChatGPT, so I expected ChatGPT to just select one from the list when it feels the need. But it actually called a new made-up function and threw my code for a loop.

For example, I have “Search A", “Search B” and “Save A” available, but ChatGPT actually tried to call “Save B”, a nonexistent function. (Which in my case, actually made sense, I should’ve implemented the function.) But for those of you out there playing with this, don’t just handle errors with function arguments, be ready to handle made-up functions as well.

And I see some people are struggling with making chatGPT use certain functions. In my limited experience, it helps a lot if you provide a system message on exactly how ChatGPT should call the function in plain language, in addition to the function description.

For example, I have a default system message that reads something like this. “If the user wants to know about A, call the search_A function, which requires argument a and b. Don’t just read the output back, summarize and use natural language.”

1 Like

And error handling with ChatGPT functions also felt like a different experience. Instead of printing everything to my screen, I can just return the error as the function output and tell ChatGPT how to respond. “The database is down. Apologize to the user and ask the user to try again later.” ChatGPT would just do that in natural language.

1 Like