Command Palette

Search for a command to run...

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

Send Only the Newest Message

The route keeps each chat's history on the server and expects the request body { id, trigger, message }: the chat id and one message. The page currently uses the default transport, which sends { id, messages, … }, so the route answers 400.

Change the transport with prepareSendMessagesRequest so the body is { id, trigger, message: messages.at(-1) }. After two questions, the second answer must say History length: 3.

What Check tests

  1. The first question gets an answer (no error)
  2. The second answer says History length: 3: the server remembered the first turn
  3. The code uses prepareSendMessagesRequest

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.