This is how I handle the "python" Function Calling in chat API. How do you handle it?

If you read my post on the function calling support I added to AlphaWave you’ll see the feedback I’m sending the model for hallucinations and invalid JSON:

I use a JSON schema validator and have the model not only repairing hallucinated function names but also fixing malformed JSON and schema errors like missing required properties.

It’s important that instead of telling the model the error it made you tell it the correction you want it to perform. It also helps if you temporarily fork the conversation history while you’re repairing the response. You don’t want to leave the hallucinated response in your conversation history as that increases the likelihood of future hallucinations.

3 Likes