Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Design a Streaming AI Text UI

MediumPython00:00
Practice interviewer
In session
5 left
00:00

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.

You need to log in / sign up to run or submit.

Problem

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.

Constraints

  • 1 <= len(events) <= 1000
  • Each event has type submit, chunk, or done
  • Each submit event contains a text string
  • Each chunk event contains a text string
  • Events are ordered as received from the interface
  • A chunk received before submit or after done must not change the output

Function Signature

def render_stream(events):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output