generative-ai-js
generative-ai-js copied to clipboard
Add streamCallbacks as an Optional Argument and Implement Stream Handling Logic : Fixes #322
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), });
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.