As you develop your tutoring application, you’ll encounter students with a wide range of learning preferences. Some thrive with clear explanations, others with challenging questions. To make your AI tutor more adaptable, let’s add support for prompt templates: reusable system prompts that can be chosen per session to deliver different tutoring experiences.
This lesson will walk you through updating your code to support multiple prompt templates, allowing every tutoring session to begin with a tailored system message—such as “explainer,” “quizmaster,” or any other style you define.
Begin by creating a new folder in your project for prompt templates:
Each .txt
file will hold the entire system prompt for that tutoring persona. For example, here’s what quizmaster.txt
could look like:
Let’s update the TutoringService
to load the right system prompt for each session. We’ll add a method that accepts a promptName
, loads the appropriate file, and uses it as the session’s system prompt.
Now, update your session creation method to accept the prompt name and use this loader:
To allow students or API clients to select a prompt template, update the StudentService
so the prompt name can be provided when creating a session:
In this lesson, we explored how to extend your application to support personalized tutoring through prompt templates. By defining different system prompt files and updating your services to select the appropriate template for each session, you can now deliver a wider range of teaching styles to your students.
As you move on to the practice exercises, try modifying or extending the StudentService
to fit different use cases. Experiment with session management for multiple students and see how you can further improve the flow. This hands-on work will deepen your understanding and prepare you for the next steps. Great job so far, and keep building!
