Skip to content

ai@2.2.2

Choose a tag to compare

@github-actions github-actions released this 17 Aug 21:58
· 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 onCompletion back to run every completion, including recursive function calls. Adds an onFinish 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 to onFinish.

    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)
        }
      })