Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feat][Js] Make ai.generateStream no longer require a double await #1602

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

inlined
Copy link
Member

@inlined inlined commented Jan 13, 2025

Fixes #1593

Rewrote generateStream so you longer need to call await to get the return value of objects that are themselves async.

As a style change I named the struct for {resolve, reject, promise} as Task because that's how I've commonly seen this design called.

The former method for passing into an async generator was a bit fragile because it depended on the exact order of the callbacks to the run loop (in fact, in my refactoring I broke it). Instead I created a buffering utility class called Channel<T>, inspired by Go channels but implements AsyncIterable for receiving.

I've had to change the copyright script from ts-node to tsx in many of my PRs because I get import vs require errors trying to load child-process. Since tsx is more officially supported I decided to change the way the script runs rather than adding module resolution annotations.

Checklist (if applicable):

@inlined inlined requested review from mbleigh and pavelgj January 13, 2025 20:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

FR: Remove double await for ai.generateStream
1 participant