AI / Apache Burr Interview questions
How do you consume results from a StreamingResultContainer?
A StreamingResultContainer behaves like a cached iterator: you loop over it to get chunks one at a time, and once it’s exhausted, call .get() to retrieve the joined final result and the updated state.
action, streaming_result = application.stream_result( halt_after="streaming_response", inputs={"prompt": prompt} ) for result in streaming_result: print(result) # one chunk at a time result, state = streaming_result.get() print(result) # the final, complete result
The async version follows the same shape with astream_result, async for, and an awaited .get():
action, async_result = await application.astream_result( halt_after="streaming_response", inputs={"prompt": prompt} ) async for result in async_result: print(result) result, state = await async_result.get()
You can also call .stream_result() on a non-streaming action — you’ll get back a container with an empty iterator whose .get() just returns the regular result, so calling code doesn’t need to special-case streaming vs non-streaming actions.
More Related questions...