Command Palette

Search for a command to run...

Hectal
Phase 5: The Vercel AI SDK
AI Frontend · Exercise 4 of 6 PreviousNext
Intermediate

Render the Parts

This route answers with some reasoning first and then the answer. Right now the page prints parts[0].text, which is empty for the assistant.

Render each message by looping over its parts: a text part becomes a <p class="text">, a reasoning part becomes a closed <details id="thinking"> with a <summary>Thinking</summary>, and any other part type renders nothing. Put the output in #messages.

What Check tests

  1. After the answer, the assistant's reply is in a .text paragraph
  2. The reasoning is in a closed <details id="thinking"> and is not mixed into the answer
  3. The user's question is shown as text too
  4. Nothing else is rendered for the assistant (step markers show nothing)

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.