Lesson 5 · Natural Language Processing
Building Chatbots
9 min
You'll be able to
- Architect a conversational AI system
- Combine retrieval with generation
- Design system prompts for assistants
A practical chatbot combines a model with a system prompt that defines its role, optional retrieval for grounded answers, and conversation history so it can follow context across turns.
Conversation loop
- Append the user's message to the conversation.
- Attach the system prompt and any retrieved context.
- Call the model to generate a reply.
- Append the reply and return it.
messages = [{"role": "system", "content": system_prompt}]
messages.append({"role": "user", "content": question})
reply = model.generate(messages)
messages.append({"role": "assistant", "content": reply})Challenge
Design an assistant
Write a 3-sentence system prompt for a friendly, beginner-focused AI tutor. Include role, tone, and one ground rule.
Knowledge Check
Chatbots
A system prompt defines the assistant's role and behaviour across the conversation.
To make a chatbot answer about private documents, you would add:
Answer all questions to submit.