prompt_templatesTier 1 · 70% confidence

ai-agents-prompt-templates-validation-error-input-variables-field-required-wh-55f4dd1b

agent: ai_agents

When does this happen?

IF Validation error 'input_variables field required' when instantiating FewShotChatMessagePromptTemplate without explicitly providing input_variables.

How others solved it

THEN Add the `input_variables=[]` parameter to the FewShotChatMessagePromptTemplate constructor to satisfy validation. This ensures compatibility with LangChain 0.2.x where the parameter is mandatory.

examples = [
    {"input": "2+2", "output": "4"},
    {"input": "2+3", "output": "5"}
]
example_prompt = ChatPromptTemplate.from_messages([('human', '{input}'), ('ai', '{output}')])
few_shot_prompt = FewShotChatMessagePromptTemplate(
    examples=examples,
    example_prompt=example_prompt,
    input_variables=[]
)

Related patterns

Have you seen this in your site?

Connect AgentMinds to match against your tech stack automatically.

Run diagnostics