Skip to content

How would I use Cloudflare D1-Backed Chat Memory AND stream the response back to the user? #7304

Closed Answered by StavrosHacker
StavrosHacker asked this question in Q&A
Discussion options

You must be logged in to vote

I ended up using a TransformStream to get each chunk and concatenate it together while the stream is being returned to the user, and once the stream is completed, it the saves the full string to D1. Fairly simple, for more info look at this: https://developers.cloudflare.com/workers/runtime-apis/streams/

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by StavrosHacker
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant