ap.Abhishek Patel

Search

Search notes, essays, projects, the library and the AI course. Use arrow keys to choose and Enter to open.

Module 02

Conversations and Your First Chatbot

Learn how chat APIs represent a conversation as a list of messages with roles, how a system prompt briefs the model and sets prompt-level guardrails, and how your application gives a stateless model memory by keeping, trimming and summarising history per session. Then put it all together and build Ask Crumb, a streaming terminal chatbot that runs on Claude, OpenAI or Gemini.

By the end of this module you can

  • structure a conversation as system, user and assistant messages for OpenAI, Claude and Gemini
  • write a system prompt with identity, facts, rules and style, and test it against a bench of tricky messages
  • explain what prompt-level guardrails can and cannot protect, and keep secrets out of prompts
  • keep a separate history per conversation and trim it to a token budget with summaries and pinned facts
  • build a streaming chatbot with history, commands and token usage display that works across three providers

Lessons

4 in this module
  1. 01Chat roles and message structureRepresent a conversation as system, user and assistant messages, explain why role labels beat one long string, and convert the same conversation for OpenAI, Claude and Gemini.25 min
  2. 02System prompts and prompt-level guardrailsWrite a system prompt with identity, job, facts, rules and style, test it against a bench of real failure cases, and explain why prompt rules are a first layer of protection rather than a guarantee.28 min
  3. 03Multi-turn conversations and historyKeep a separate history for every conversation, resend it each turn, and trim long chats to a token budget using running summaries and pinned facts so nothing important is lost.28 min
  4. 04Build your first end-to-end chatbotBuild Ask Crumb, a streaming terminal chatbot with a system prompt, conversation history, /reset and /usage commands, token-budget trimming and a switch between Claude, OpenAI and Gemini.Lab60 min