generative-ai-js
generative-ai-js copied to clipboard
Enhance generateContentStream with streamCallbacks support. Fixes #322 #401
Add streamCallbacks to generateContentStream
Changes
- Added a
StreamCallbacksinterface withonDataandonDonecallback functions - Updated
generateContentStreamto accept and process the callbacks
Example Usage
await model.generateContentStream("Tell me a joke", {}, {
onData: (chunk) => process.stdout.write(chunk),
onDone: (fullText) => console.log("\nFinal output:", fullText),
});
Testing
The changes have been tested with both unit tests and manual validation.