Intermediate
Say Why the Answer Ended
readSSE is ready: it yields { type: "text", text } and { type: "finish", reason } parts. Two buttons ask the route a short and a long question.
Show the answer in #answer as it arrives. When the stream finishes with the reason length, show the sentence This answer was cut short. in #note. For a normal finish #note must stay empty. Clear both at the start of each question.
What Check tests
- A short question shows its answer and leaves
#noteempty - A long question shows the cut text and the note
This answer was cut short. - Asking a short question again clears the note
Stuck? One hint at a time
The solution unlocks after your first Check. Try first: that is where the learning happens.
Runs in your browser. Your code is saved here.
Your page
Press Run to see the page.
Console
Nothing logged yet.