Bird
0
0

You want to create a prompt that always asks about the weather but lets the user specify the city later. How do you use PartialPromptTemplate to achieve this?

hard📝 Application Q8 of 15
LangChain - Prompt Templates
You want to create a prompt that always asks about the weather but lets the user specify the city later. How do you use PartialPromptTemplate to achieve this?
AUse partial to fill city="weather" and leave topic variable
BCreate a prompt with only {city} variable and fill it directly
CCreate two separate prompts and combine them manually
DCreate a base prompt with variables {topic} and {city}, then partial fill topic="weather"
Step-by-Step Solution
Solution:
  1. Step 1: Define base prompt with both variables

    Start with a prompt template having {topic} and {city} variables.
  2. Step 2: Use partial to fix topic="weather"

    Partial fill the topic variable to "weather", leaving city variable open.
  3. Final Answer:

    Create a base prompt with variables {topic} and {city}, then partial fill topic="weather" -> Option D
  4. Quick Check:

    Partial fixes topic, city remains variable [OK]
Quick Trick: Partial fill fixed parts, leave others variable [OK]
Common Mistakes:
  • Filling wrong variable with partial
  • Not defining all needed variables in base prompt
  • Trying to combine prompts manually unnecessarily

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LangChain Quizzes