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

Enhance generateContentStream with streamCallbacks support. Fixes #322

Open cestercian opened this issue 9 months ago • 2 comments

  • Adds streamCallbacks as an optional argument to generateContentStream.
  • Enables users to receive text responses via callbacks without handling Node.js streams.
  • Includes test cases for the new functionality.

Example Usage:

await model.generateContentStream("Tell me a joke", {}, {
   onData: (chunk: string) => process.stdout.write(chunk),  
   onDone: (fullText: string) => console.log("\nFinal output:", fullText),
});

cestercian avatar Mar 08 '25 22:03 cestercian

I am working on this issue let me know if its up to expectation

demoncoder-crypto avatar Mar 08 '25 22:03 demoncoder-crypto

Hey @avinesh2101 .Thanks for pointing that out. I didn’t realize this change had already been proposed in PR #371. I’ll make sure to check existing PRs more carefully next time. Appreciate the guidance! I’d love to contribute in other ways—if there are any areas that need help, I’d be happy to take a look.

cestercian avatar Mar 10 '25 10:03 cestercian