Patch Changes
-
84e0cc8: Add experimental_StreamData and new opt-in wire protocol to enable streaming additional data. See #425.
Changes
onCompletion
back to run every completion, including recursive function calls. Adds anonFinish
callback that runs once everything has streamed. For users not using experimental function handling on the server,onCompletion
functions the same but it's recommended you migrate toonFinish
.If you're using experimental function handlers on the server and caching via
onCompletion
,
you may want to adjust your caching code to account for recursive calls so the same key isn't used.let depth = 0 const stream = OpenAIStream(response, { async onCompletion(completion) { depth++ await kv.set(key + '_' + depth, completion) await kv.expire(key + '_' + depth, 60 * 60) } })