新版文档(v1.x)
langchain
errors
INVALID_PROMPT_INPUT

INVALID_PROMPT_INPUT

{/* TODO: fix link when porting page */} Occurs when a prompt template (opens in a new tab) received missing or invalid input variables.

Troubleshooting

To resolve this error, you can:

  1. Review your prompt template for correctness. When using f-string formats, ensure proper escaping of curly braces:
    • Use {{ for single braces in f-strings
    • Use {{{{ for double braces in f-strings
  2. When using MessagesPlaceholder components, confirm you're passing message arrays or message-like objects. If using shorthand tuples, wrap variable names in curly braces like ["placeholder", "{messages}"]
  3. Debug by examining actual inputs to your prompt template by using LangSmith or logging to verify they match expectations
  4. If sourcing prompts from LangChain Prompt Hub (opens in a new tab), isolate and test the prompt with sample inputs to ensure it functions as intended