Back to All questionsHow do I resolve KeyError: "Input to PromptTemplate is missing variables {'query'}"?
Ask questionpython
from langchain_core.prompts import PromptTemplate
prompt = PromptTemplate(
template="Answer this: {query}",
input_variables=["query"]
)
formatted = prompt.format(question="What is AI?")
Error:
text
KeyError: "Input to PromptTemplate is missing variables {'query'}. Expected: ['query']
Received: ['question']"
1 answerHelpful solutions from the community
Fix:
python
formatted = prompt.format(query="What is AI?")
Need a custom solution?
Tell us about your project and get help tailored to your problem.
Contact usHave an answer? Join the conversation.
Everyone can read. Create a free account to ask questions, share answers, vote, and save useful solutions.