openai-node
openai-node copied to clipboard
functionCallResult never get's called in the frontend with ChatCompletionStream
Confirm this is a Node library issue and not an underlying OpenAI API issue
- [X] This is an issue with the Node library
Describe the bug
In my backend I do:
const steam = client.beta.chat.completions.runTools({})
return steam.toReadableStream()
And in my frontend I do:
const runner = ChatCompletionStream.fromReadableStream( response.body )
runner.on('message', (message) => {
messages.value.push(message)
})
This works but after the role:assistant with tool_calls it doesn't push the tool_call results to the messages array. In the frontend also runner.on('functionCallResult') never gets called.
This means that next calls fail because after a tool call we must pass the tool call results.
How can I get the tool call function response to show up in messages?
To Reproduce
- return a stream to the frontend:
const steam = client.beta.chat.completions.runTools({}) return steam.toReadableStream()
-
read the stream with ChatCompletionStream
-
fail to get the function response as message
P.s I've also tested with ChatCompletionStreamingRunner and it's the same
Code snippets
No response
OS
mac latest
Node version
22
Library version
latest