LangChain prompt templates: 'missing variables' error when the prompt contains JSON examples
@devsingh05▲ 10 net votes
ChatPromptTemplate and PromptTemplate treat every {name} as a variable, so a JSON example like {"name": "x"} in the prompt text is parsed as variables and raises a missing-variables KeyError or ValueError. Escape literal braces by doubling them ({{ and }}), or pass the example in as a variable. Python str.format and f-strings have the same rule.