๐งชTDD Challengeยทintermediateยทโฑ๏ธ 30โ45mยทโญ 175 XP
M-012Build a Streaming Token Renderer
Description
Nebula Corp's chatbot waits for the full LLM response before showing anything โ users think it's broken. Build a streaming renderer that processes Server-Sent Events (SSE), displays tokens as they arrive, tracks time-to-first-token, and handles cancellation. The renderer should buffer partial chunks, detect the [DONE] signal, and report streaming metrics.
Test Cases (3)
Processes a token chunk
Should extract token from SSE data
Input:testProcessToken()
Expected:CONTAINS:Hello
Detects done signal
Should recognize [DONE] and return full text
Input:testDoneSignal()
Expected:CONTAINS:done
Cancellation returns partial text
Should return accumulated text on cancel
Input:testCancel()
Expected:CONTAINS:Hello world
Related Lessons
Click Run / Check to validate your solution