ai@2.2.2
·
6954 commits
to main
since this release
Patch Changes
-
84e0cc8: Add experimental_StreamData and new opt-in wire protocol to enable streaming additional data. See #425.
Changes
onCompletionback to run every completion, including recursive function calls. Adds anonFinishcallback that runs once everything has streamed. For users not using experimental function handling on the server,onCompletionfunctions 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) } })