Skip to content

Conversation

danielamitay
Copy link
Contributor

@lgrammel Please take a look! This PR simply adds onChunk to streamObject to mirror the same behavior for streamText.

Background

  • Parity with streamText as well as easier devex for performing updates

Summary

  • Implement onChunk for streamObject
  • Add unit tests
  • Add documentation

Manual Verification

  • Tests pass
  • Manual integration into existing codebase works as expected
  • onChunk successfully used to show stream updates

Tasks

  • Tests have been added / updated (for bug fixes / features)
  • Documentation has been added / updated (for bug fixes / features)
  • A patch changeset for relevant packages has been added (for bug fixes / features - run pnpm changeset in the project root)
  • Formatting issues have been fixed (run pnpm prettier-fix in the project root)
  • I have reviewed this pull request (self-review)


if (chunk.type === 'error') {
onError({ error: wrapGatewayError(chunk.error) });
await onError({ error: wrapGatewayError(chunk.error) });
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

await was missing here from onError, which returns a promise and is also awaited in streamText.

@param onChunk - Callback that is called for each chunk of the stream. The stream processing will pause until the callback promise is resolved.
@param onError - Callback that is invoked when an error occurs during streaming. You can use it to log errors.
@param onFinish - Callback that is called when the LLM response and the final object validation are finished.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

onError and onFinish codedocs were missing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants