Szekeres Géza
Szekeres Géza6mo ago

Streaming assistant in Loop

Hi, If I use the default OpenAI Assistant (Stream Response) node in Loop, it seems like it ain't wait the stream to finish and it submits the next message even if the first streaming (and run) is still running.. I works as single node, without loop, but in loop it gives multiple run error.. Please help!
No description
Solution:
@Gaurav Chadha I have updated your Streaming Assistant node, added Promise for Stream Handling and now the function assistant awaits the handleStream completion.. please check and consider update so others could use this as well:
Jump to solution
4 Replies
AI Support
AI Support6mo ago
It sounds like you're encountering an issue with the OpenAI Assistant (Stream Response) node when used inside a loop in BuildShip. The error message you're seeing indicates that multiple runs are being triggered before the previous one has completed, which is causing a conflict. To address this issue, you might consider implementing a mechanism to ensure that each streaming response completes before the next one begins. One approach could be to use a delay or wait node to pause the loop until the current streaming response is finished. For more detailed guidance, you can refer to the official BuildShip documentation on handling loops and stream responses. Here is a link to the relevant documentation page: BuildShip Documentation - OpenAI Assistant Node If you continue to experience issues, you might also want to check if there are any specific configurations or settings in the OpenAI Assistant node that can help manage the stream responses more effectively. Source: - BuildShip Documentation - OpenAI Assistant Node
Szekeres Géza
Szekeres GézaOP6mo ago
Hi @Gaurav Chadha! I am aware what is the problem, however it seems like your Streaming Assistant node returns without waiting the final result.. I've tried to use "await" before your handleStream functions but still, it should return with the node only .on("end") or .on("error").. Btw the link you sent seems to be broken. Thanks in advance!
Solution
Szekeres Géza
Szekeres Géza6mo ago
@Gaurav Chadha I have updated your Streaming Assistant node, added Promise for Stream Handling and now the function assistant awaits the handleStream completion.. please check and consider update so others could use this as well:
Gaurav Chadha
Gaurav Chadha6mo ago
Oh, thanks for pointing, here's the correct link - https://docs.buildship.com/ai-assistant/openai-streaming-assistant. Thanks for sharing, we appreciate it. cc @nithinrdy can you check this? This also solves the undefined node issue we discussed.