Performing controlled actions while streaming #4438
-
I read the documentation, but I can't find anything related to executing actions while streaming, at least in React (NextJS). For example, let's say I want to call my It seems the best option is to call fetch to the API and handle SSE manually without the SDK, so I can perform actions per chunk received. I noticed that There are some workarounds, like the one in this pull request: #3252, but it's like something is off. Any help would be much appreciated! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
Are you using useChat? Assuming so because of the mentioned PR. One way people have been doing this is with Can you share more about your use case? I might have other approaches depending on what actions you're trying to perform per chunk |
Beta Was this translation helpful? Give feedback.
They've open sourced a template for that (it uses tool calls, which then use further ai calls)
https://github.com/vercel/ai-chatbot
My link at the very top of the thread shows the function calls to "createDocument" which might give you a few ideas.