Back to All questionsHow do I fix KeyError: 'Invalid prompt schema' caused by literal braces in JSON output prompts?
Ask questionpython
from langchain_core.prompts import PromptTemplate
prompt = PromptTemplate(
template="""
Summarize into JSON:
{{"name": "{name}", "size": "{size}"}}
""",
input_variables=["name", "size"]
)
Error:
text
KeyError: 'Invalid prompt schema; check for mismatched or missing input parameters'
1 answerHelpful solutions from the community
Fix:
python
prompt = PromptTemplate(
template="""
Summarize into JSON:
{{{{"name": "{name}", "size": "{size}"}}}}
""",
input_variables=["name", "size"]
)
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.