Thuta Learning
LangChain
BasicAIAdvanced

Prompt Templates

LangChainLesson 5

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.

Updated on

Progress is saved only in this browser on this device. It isn't synced to other devices.

Report a problem with this lessonOpens your email app with this lesson's address filled in — nothing is sent until you send it.

Prompt Templates | Thuta Learning