Skip to content

Commit

Permalink
Flush the output after each print in streaming mode (#213)
Browse files Browse the repository at this point in the history
  • Loading branch information
mandel authored Dec 12, 2024
1 parent 4a4759e commit ad048b8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/pdl/pdl_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def schedule(
text = stringify(result)
else:
text = colored(stringify(result), msg.color)
print(text, end="")
print(text, end="", flush=True)
todo_next.append((i, gen, None))
case YieldBackgroundMessage(background=background):
if len(background) > 0 and background[0]["role"] == _LAST_ROLE:
Expand All @@ -127,7 +127,7 @@ def schedule(
s += "\n".join(
[f"{msg['role']}: {msg['content']}" for msg in background]
)
print(s, end="")
print(s, end="", flush=True)
todo_next.append((i, gen, None))
case ModelCallMessage():
text_msg = BamModel.generate_text(
Expand Down

0 comments on commit ad048b8

Please sign in to comment.