generative-ai-js icon indicating copy to clipboard operation
generative-ai-js copied to clipboard

Add streamCallbacks as an Optional Argument and Implement Stream Handling Logic : Fixes #322

Open Sufiyan-MSA opened this issue 7 months ago • 1 comments

Added streamCallbacks as an optional argument to generateContentStream.

This allows users to avoid dealing directly with Node.js streams and instead receive the streamed text via simple callback functions.

Example usage:

await model.generateContentStream("What is 2 + 2", {},{ onData(chunk: string) => console.log(chunk), onDone(fullText: string) => console.log(fullText), });

Sufiyan-MSA avatar Apr 05 '25 19:04 Sufiyan-MSA

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

google-cla[bot] avatar Apr 05 '25 19:04 google-cla[bot]