How to handle multiple functions callings in GPT API

0 sats
0 comments

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.

I'm a passionate Front End developer with a love for building unique things. I love a good challenge and am always looking to do stuff that I haven't done before.

View on Nostr

View on Nostr ↗