Stream

One sentence, in pieces

stream=True makes start yield pieces as they arrive. You print each piece instead of waiting for the whole string.

The loop is the result. end="" keeps the pieces on one line.

Example

from praisonai import Agent

agent = Agent(instructions="You are a helpful assistant")
for chunk in agent.start("Explain streaming in one sentence", stream=True):
    print(chunk, end="", flush=True)
print()

Try it Yourself

Example explained

  • stream — True yields pieces. False returns the whole answer.
  • chunk — One piece of the answer.

Reference: documentation