
Help me refactor this function
Two options: pull the side effect out, or inline the retry loop.
for await (const chunk of stream) { if (chunk.choices[0].delta.tool_calls) { ... } else { ui.append(chunk.choices[0].delta.content); }}// OpenAI SSE format, every provider, no translationfor await (const chunk of stream) { if (chunk.choices[0].delta.tool_calls) { ... } else { ui.append(chunk.choices[0].delta.content); }}// OpenAI SSE format, every provider, no translation