Get Streaming Chunks as they arrive in useChat #1644
Unanswered
alokwhitewolf
asked this question in
Help
Replies: 3 comments
-
Try this
|
Beta Was this translation helpful? Give feedback.
0 replies
-
It would be great to have an |
Beta Was this translation helpful? Give feedback.
0 replies
-
Can't do it in |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Context - I want to extract individual chunks sent by StreamingTextResponse in the backend, that is used by useChat in the client side.
Existing Implementation
I am currently trying to use onResponse callback to read the data. Current implementation
I am having to also use setMessages, as it seems like if i use
const reader = response.body?.getReader();
, the incoming response is not updated in themessages
object. However, with this implementation, it seems like themessages
array always seems to have one less element ( for eg, the last user sent message is never included ), so the last message that the user sent gets skippedAny help on how I can - go through each message chunk while still maintaining the same behaviour of messages/useChat?
Environment Setup
SDK Version : 3.0.23
Environment : TS / Next.js
Beta Was this translation helpful? Give feedback.
All reactions