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

Async Assistant Streaming Helpers #879

Open
1 task done
metaskills opened this issue Jun 5, 2024 · 7 comments
Open
1 task done

Async Assistant Streaming Helpers #879

metaskills opened this issue Jun 5, 2024 · 7 comments

Comments

@metaskills
Copy link

Confirm this is a feature request for the Node library and not the underlying OpenAI API.

  • This is a feature request for the Node library

Describe the feature or improvement you're requesting

When using the Assistant Streaming Helpers it is sometimes desirable to have an async/await level of control for the event listener. For example, an imageFileDone listener that would move a file to a new destination as part of tools being submitted.

Additional context

I am the author of Experts.js (https://github.com/metaskills/experts) and I felt this particular pain point in a few of my projects. I've not heard of other's needs for this behavior. That said, I thought that would be helpful for more context.

https://github.com/metaskills/experts?tab=readme-ov-file#streaming--events

Thanks y'all.

@meorphis
Copy link
Contributor

meorphis commented Jun 7, 2024

Thanks for reporting @metaskills. I'll route this one to the relevant team to track as a feature request.

@rattrayalex
Copy link
Collaborator

Thanks for the suggestion @metaskills . Could you provide a more concrete snippet of the code you'd like to write, and what you have to write today?

@metaskills
Copy link
Author

Sure, in the Experts.js link there is a UAT test for a contrived product assistant that generates an image using data with code interpreter. Illustrated here and code. This is the "imageFileDone listener" I mentioned above.

https://github.com/metaskills/experts/blob/main/test/fixtures/productsTool.js#L48-L53

Screenshot 2024-07-10 at 7 48 48 AM

@Ethan-Arrowood
Copy link

Hi @metaskills I believe all you would need is the Node.js events .once() api: https://nodejs.org/api/events.html#eventsonceemitter-name-options

This will let you async/await on any event emitter.

@rattrayalex
Copy link
Collaborator

Hmm, we offer async/await await stream.finalMessages() : Promise<Message[]> and await stream.finalRunSteps(): Promise<RunStep[]>. Which additional events would you also like to await? I am not aware of an imageFileDone event in the assistants API.

@metaskills
Copy link
Author

metaskills commented Jul 12, 2024

@Ethan-Arrowood I had no idea once offered that. Still thinking it would not work... well, maybe. I would have to rearchitect the interface of all my user-defined events and re-attach them "once" for each run. Sounds odd tho, but wiling to try if that is really the fix.

@rattrayalex Those are the assistant methods defined here. My request is for the assistant events defined here.

@rattrayalex
Copy link
Collaborator

Ah, silly me. Thanks very much. We'll look into that…

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants