Project 2: Product Review Generator
AI Engineer
Builds on these lessons
Current Task
Objective
PromptTemplate declares which variables a template requires up front, validating them before the LLM is ever called.
Task: build a PromptTemplate with three input_variables and format it, then print the result.
index.py
from langchain_core.prompts import PromptTemplate
prompt = PromptTemplate(
template="Write a {tone} product review for {name} about our {product}.",
input_variables=["tone", "name", "product"],
)
print(prompt.format(tone="positive", name="Alice", product="headphones"))
* Hint: Correct characters turn green, incorrect ones turn red.
Live Preview
🖼️
Verify your code to see the preview