From 3d072cab07b8bea3cc25ccda2d04408ab5359982 Mon Sep 17 00:00:00 2001 From: goulustis Date: Thu, 12 Feb 2026 16:46:08 +0800 Subject: [PATCH] print flush for the streaming out put instead --- tests/test_dashscope_client.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/test_dashscope_client.py b/tests/test_dashscope_client.py index 778bcb7..d514bec 100644 --- a/tests/test_dashscope_client.py +++ b/tests/test_dashscope_client.py @@ -77,10 +77,12 @@ def main(): # 避免偶发回退 delta = current_text if delta: - u = delta + u = delta last_text = current_text - logger.info(f"from stream: {u}") + # For streaming responses, print incrementally to stdout and flush + # so the user can see tokens as they arrive. + print(u, end="", flush=True) except TypeError: # 非流式回落(一次性返回) if responses.status_code != HTTPStatus.OK: