openai-node icon indicating copy to clipboard operation
openai-node copied to clipboard

fix(accumulateDelta): AssistantStream accumulateDelta toolCall (#771)

Open A4F54B opened this issue 1 year ago • 2 comments

  • [x] I understand that this repository is auto-generated and my pull request may not be merged

Changes being requested

One solution I see for this problem is to call openai.beta.threads.runs.retrieve. This PR fixes this bug and allows multiple toolCalls to return, so that calls can be listened to in toolCallCreated and toolCallDone, thus avoiding polling retrieve and improving efficiency. In addition, with this modification, users no longer need to manually assemble the arguments string, they only need to use function.arguments in callTool in the toolCallDone callback.

stream.on("toolCallDone",async (toolCall) =>{
  console.log(toolCall.function.arguments)
})

Additional context & links

#771

https://community.openai.com/t/how-to-properly-handle-the-function-call-in-assistant-streaming-node-js/687193

A4F54B avatar May 22 '24 14:05 A4F54B