Beginner
Resend the History
The route /api/chat replies with how many messages it received. Type a question into #prompt and click #send: show the reply in #answer.
The model has no memory, so the request must carry the whole conversation so far: every earlier question and every earlier answer, then the new question. Keep the conversation in the history array.
After the first question the reply says I received 1 message. After the second question it must say I received 3 messages.
What Check tests
- The first question gets
I received 1 message. - The second question sends three messages: question, answer, question
- The third question sends five messages
- An empty question sends 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.