Command Palette

Search for a command to run...

Hectal
Phase 12: AI That Runs in the Browser
AI Frontend · Exercise 5 of 5 Previous
Advanced

Device First, Then the Server

Build the hybrid. Clicking #ask should first try askDevice(question, supported), where supported is the checkbox #supported. If it returns with confidence of at least 0.5, show its text in #answer and on this device in #source.

If the device throws or is not sure, POST { question } to /api/chat. On success show the text and from server. If the server answers with a failure status, show Sorry, I cannot answer right now. and none.

What Check tests

  1. A refund question is answered on the device
  2. A question the device is unsure about goes to the server
  3. When the device is unsupported, the server answers
  4. When the server is busy, the user gets a clear message

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.