Bird
0
0

Which of the following is the correct syntax to create a prompt template in Langchain?

easy📝 Syntax Q3 of 15
LangChain - Prompt Templates
Which of the following is the correct syntax to create a prompt template in Langchain?
Aprompt = PromptTemplate("Hello {name}")
Bprompt = PromptTemplate(template="Hello {name}")
Cprompt = PromptTemplate.create("Hello {name}")
Dprompt = new PromptTemplate(template="Hello {name}")
Step-by-Step Solution
Solution:
  1. Step 1: Recall PromptTemplate constructor syntax

    PromptTemplate requires a named argument 'template' with the string template.
  2. Step 2: Check each option

    prompt = PromptTemplate(template="Hello {name}") uses correct named argument syntax. prompt = PromptTemplate("Hello {name}") misses 'template=' keyword. prompt = PromptTemplate.create("Hello {name}") uses non-existent create method. prompt = new PromptTemplate(template="Hello {name}") uses invalid 'new' keyword in Python.
  3. Final Answer:

    prompt = PromptTemplate(template="Hello {name}") -> Option B
  4. Quick Check:

    PromptTemplate syntax = named template argument [OK]
Quick Trick: Use named argument 'template' when creating PromptTemplate [OK]
Common Mistakes:
  • Omitting 'template=' keyword
  • Using JavaScript 'new' keyword in Python
  • Calling non-existent create() method

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LangChain Quizzes