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
- The first question gets an answer (no error)
- The second answer says
History length: 3: the server remembered the first turn - 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.