After calling client.beta.threads.runs.submitToolOutputsStream() I am successfully console logging a ‘thread.run.completed’ event, but the event is not being handled by the event listener in the run() stream. Here is the code in question:
submitToolOutputsStream():
const stream = client.beta.threads.runs.submitToolOutputsStream(
threadId,
runId,
{ tool_outputs: toolOutputs }
);
// iterate over each incoming event
for await (const event of stream) {
if (event.event === 'thread.run.completed') {
console.log('Event handled: thread.run.completed: ' + event.data.id);
}
}
And my event listener in the run() stream:
run =() => {...
const stream: any = openai.beta.threads.runs.stream(threadId, {
assistant_id: agentData.assistantId,
});
stream.on('event', async (event: any) => {
if (event.event === 'thread.run.requires_action') {
// requires action logic...
} else if (event.event === 'thread.run.completed') {
// run completed logic...
});
...}
For some reason the listener is not receiving the ‘thread.run.completed’ event from the Assistant, however I am able to console log it in submitToolOutputsStream() - so I’m sure it’s being emitted.
I see on this page we are provided example code, and that example code contains a class with an inherited this.emit emitter. But I’m not sure how that transfers over to a function-based architecture.
Any help is greatly appreciated.