ai-chatbot
ai-chatbot copied to clipboard
When calling a tool on the client side, tool-call and tool-results messages are not saving to the database
Hi Vercel Team,
Great work with this AI Chatbot Starter Template, it's fantastic 👏
When setting up client-side tool calling, I've noticed that the results of these tool calls are currently not correctly stored in the database. I've followed this guide to set it up: https://sdk.vercel.ai/docs/ai-sdk-ui/chatbot-with-tool-calling#chatbot-with-tools
I've forked this repo and added an example commit to demonstrate this + to reproduce it easily:
https://github.com/tobiasbueschel/ai-chatbot/commit/a673798b513b86b3c3f2559bced5ea557d950c57
https://github.com/tobiasbueschel/ai-chatbot/blob/a673798b513b86b3c3f2559bced5ea557d950c57/components/chat.tsx#L43-L69
This is what I see in the DB when running the client-side tool:
- notice that my initial user message has been stored twice
-
tool-call
andtool-result
is missing entirely
And here is what is stored in the DB when running a server-side tool
On that note, as other people might also find examples for client-side tools helpful, shall we add such an example to the tools that are already registered in this starter template?
Thanks 🙏