gen returns a Generation object, which is a wrapper around the response from the LM.
Enabling streaming in APPL is simple. Just set the stream parameter to True when calling gen. The return is a generator that yields the response in chunks, but you can still access the complete response.
importapplfromapplimportppl,recordsfromappl.funcimportgenappl.init()@ppldeffunc(stream=True):# adopted from https://cookbook.openai.com/examples/how_to_stream_completions"Count to 100, with a comma between each number and no newlines. E.g., 1, 2, 3, ..."returngen(stream=stream)content=func(stream=False)print(f"Content: {content}")content=func(stream=True)print(f"Content: {content}")