Skip to content

Commit ad048b8

Browse files
authored
Flush the output after each print in streaming mode (#213)
1 parent 4a4759e commit ad048b8

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/pdl/pdl_scheduler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def schedule(
115115
text = stringify(result)
116116
else:
117117
text = colored(stringify(result), msg.color)
118-
print(text, end="")
118+
print(text, end="", flush=True)
119119
todo_next.append((i, gen, None))
120120
case YieldBackgroundMessage(background=background):
121121
if len(background) > 0 and background[0]["role"] == _LAST_ROLE:
@@ -127,7 +127,7 @@ def schedule(
127127
s += "\n".join(
128128
[f"{msg['role']}: {msg['content']}" for msg in background]
129129
)
130-
print(s, end="")
130+
print(s, end="", flush=True)
131131
todo_next.append((i, gen, None))
132132
case ModelCallMessage():
133133
text_msg = BamModel.generate_text(

0 commit comments

Comments
 (0)