It's a bit difficult to comprehend what's going on in the useChat hook, where objects are constructed and deconstructed multiple times. It could do with a bit of simplification. Perhaps passing a ChatMessage as the newMessage and then a ChatMesage[] as the history to the sendChatMessage. Currently it's taking a string, which is limited considering new capabilities of AI such as documents and images processing
It's a bit difficult to comprehend what's going on in the useChat hook, where objects are constructed and deconstructed multiple times. It could do with a bit of simplification. Perhaps passing a ChatMessage as the newMessage and then a ChatMesage[] as the history to the sendChatMessage. Currently it's taking a string, which is limited considering new capabilities of AI such as documents and images processing