Streaming with tools, only first chunk has the ID

Initialized Chat with model: gpt-3.5-turbo
Making chat completions call.
[ChoiceDeltaToolCall(index=0, id='call_HNux2G4SUDnSuyLiv0OWQyjx', function=ChoiceDeltaToolCallFunction(arguments='', name='get_current_weather'), type='function')]
[ChoiceDeltaToolCall(index=0, id=None, function=ChoiceDeltaToolCallFunction(arguments='{\n', name=None), type=None)]
[ChoiceDeltaToolCall(index=0, id=None, function=ChoiceDeltaToolCallFunction(arguments=' ', name=None), type=None)]
[ChoiceDeltaToolCall(index=0, id=None, function=ChoiceDeltaToolCallFunction(arguments=' "', name=None), type=None)]
[ChoiceDeltaToolCall(index=0, id=None, function=ChoiceDeltaToolCallFunction(arguments='location', name=None), type=None)]

This means with multiple tool calls grouping is weird, unless I just segment by the order the chunks arrive and count the chunk with the name and ID as the start of a new call.

depending on what streaming lib you’re using, you have to do this anyways. they recently introduced a bug (or feature) into the streaming api where they force you to parse the frames statefully. so parsing chunks statefully is just them following one of their design patterns, I guess.