Your question is Design a Streaming AI Text UI. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Create a simple input box and submit button that renders streaming text from an AI.
Represent the interaction as an ordered list of events and return the UI state after each event. A submit event starts a new response and clears the input, chunk appends text while streaming, and done ends the response. The function receives events, a list of dictionaries, and returns state snapshots containing input, output, and streaming.
def render_stream(events):