Thuta Learning
BasicAIadvanced

Prompt Templates

Relax. We'll talk through this in plain words — no textbook voice.

Prompt Templates let you dynamically build prompts from user input and other information, keeping your LLM inputs reusable and consistent.

python
from langchain.prompts import PromptTemplate

prompt_template = PromptTemplate.from_template(
    "Tell me a short joke about {subject}."
)

# Create a prompt by formatting the template
prompt = prompt_template.format(subject="a cat")

print(prompt)
# This prompt can now be sent to an LLM.
You should see
Tell me a short joke about a cat.
Prompt Templates | Thuta Learning