Programming

JavaScript: summary of the 8 AI lessons

What was learned from the API to the agent, and what you can build next.

All lessons · JavaScript lessons: learn from scratch

The 8 lessons

Each lesson is one step. The order is this.

  1. API: send a question to Gemini with fetch and POST.
  2. async/await: wait for the answer and hold the error with try and catch.
  3. .env: do not keep the key in the code, .gitignore and a Vercel variable.
  4. systemInstruction: a hidden role, a length and a refusal.
  5. Memory: the user and model turns, the array goes on every request.
  6. JSON: quiz questions with responseMimeType and JSON.parse.
  7. RAG: find the matching paragraph and write only from it.
  8. Agent: tools, functionCall and functionResponse.

You can build these

These are not ready tools on the site. They are the next things you build from the parts you learned.

  1. A chat page: systemInstruction changes, the history stays in an array.
  2. A quiz page: the JSON questions become buttons and the right answers are counted.
  3. A word list: a word is kept and the AI builds one sentence from it.

Later

  1. Turn the web page into an Android app with Capacitor or Expo.
  2. Closed testing in Play Console: the app is given first to a small tester group.
  3. Store PDF pieces in Supabase pgvector and search them with RAG.
  4. Sign-in: each user should have their own chat history.

Author: Nibras Code