PromptTemplate basics
📖 Scenario: You are building a simple chatbot that uses a prompt template to ask questions. The prompt template will help you create messages with placeholders for user input.
🎯 Goal: Create a PromptTemplate that takes a user's name and question, then formats a message asking the question politely.
📋 What You'll Learn
Create a
PromptTemplate with input variables name and question.Set the template string to: 'Hello {name}, can you please answer: {question}?'
Use the
format method to fill in the template with example values.Print the formatted prompt message.
💡 Why This Matters
🌍 Real World
PromptTemplate helps create dynamic messages for chatbots, AI assistants, or any system that needs to ask questions or generate text with user input.
💼 Career
Understanding PromptTemplate is useful for AI developers, chatbot builders, and anyone working with language models to create flexible and reusable prompts.
Progress0 / 4 steps