STORY
How to handle multiple functions callings in GPT API
AUTHOR
Joined 2022.06.04
DATE
VOTES
sats
COMMENTS

How to handle multiple functions callings in GPT API

In the case where the user's prompt might contain multiple commands that needs to call multiple functions, the GPT API will return only one function at a time. To get to know that other functions should also be called, we need to make the exact same request again but with appending the previous function call response, & only then, it'll return a call 2nd function response.

& this should be done recursively until it returns a response that is NOT a function call...

This of course at least doubles the costs of the API usage. Because in the minimum case where the user prompt contains a single command that translates to a single function call, we will need to make one other request that will returns a response that is not a function call & then stop.

I looked around for some better way, but couldn't find any.
So if anyone happened to have found a solution or have some thoughts on that, please share them with me.