To consume streaming outputs, wrap your model or pipeline with lazyllm.StreamCallHelper. This allows you to iterate over the model's output using a for loop.
If the model is part of a pipeline (Flow), wrap the outermost pipeline object instead of the model itself.
# For a standalone model
model = lazyllm.TrainableModule('qwen2-1.5b', stream=True)
model = lazyllm.StreamCallHelper(model)
for msg in model('hello'):
print(msg)
# For a model within a pipeline (Flow)
model = lazyllm.TrainableModule('qwen2-1.5b', stream=True)
ppl = lazyllm.pipeline(model)
ppl = lazyllm.StreamCallHelper(ppl)
for msg in ppl('hello'):
print(msg)