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.
- API: send a question to Gemini with fetch and POST.
- async/await: wait for the answer and hold the error with try and catch.
- .env: do not keep the key in the code, .gitignore and a Vercel variable.
- systemInstruction: a hidden role, a length and a refusal.
- Memory: the user and model turns, the array goes on every request.
- JSON: quiz questions with responseMimeType and JSON.parse.
- RAG: find the matching paragraph and write only from it.
- 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.
- A chat page: systemInstruction changes, the history stays in an array.
- A quiz page: the JSON questions become buttons and the right answers are counted.
- A word list: a word is kept and the AI builds one sentence from it.
Later
- Turn the web page into an Android app with Capacitor or Expo.
- Closed testing in Play Console: the app is given first to a small tester group.
- Store PDF pieces in Supabase pgvector and search them with RAG.
- Sign-in: each user should have their own chat history.