[feature] provide a callback to useChat for when messages are completed
The useChat hook has an onFinish callback which fires when everything is completed. With the new experimental feature to stream additional data, the onFinish callback fires not after the tokens are completed but after any data is also done loading.
We need to be able to tell when the messages are completed so that we can show a loading state for the additional data that is being calculated based off of the message received. It would be nice to have an onCompleted callback added to the useChat hook on the client side. It may also look like a isMessageLoading added to the isLoading boolean to indicate the difference.
I support an onCompletion to closer align the client API and server API. PR's welcome!
Great suggestion @dilanustek. I've started a draft PR for this here: https://github.com/vercel/ai/pull/554
in ai sdk the finish hook is invoked when the response is complete