autogen
autogen copied to clipboard
fix: ensure streaming chunks are immediately flushed to console
Added flush=True to the aprint call when handling ModelClientStreamingChunkEvent message to ensure each chunk is immediately displayed as it arrives.
Why are these changes needed?
When handling ModelClientStreamingChunkEvent message, streaming chunks weren't guaranteed to be displayed immediately, as Python's stdout might buffer output without an explicit flush instruction. This could cause visual delays between when chunk_event objects are added to the message queue and when users actually see the content rendered in the console.
Related issue number
None
Checks
- [x] I've included any doc changes needed for https://microsoft.github.io/autogen/. See https://github.com/microsoft/autogen/blob/main/CONTRIBUTING.md to build and test documentation locally.
- [x] I've added tests (if relevant) corresponding to the changes introduced in this PR.
- [x] I've made sure all auto checks have passed.