> ## Documentation Index
> Fetch the complete documentation index at: https://cndoc-langchain.site/llms.txt
> Use this file to discover all available pages before exploring further.

# INVALID_PROMPT_INPUT

当[提示模板](https://github.com/langchain-ai/langchain/blob/v0.3/docs/docs/concepts/prompt_templates.mdx)接收到缺失或无效的输入变量时，会出现此错误。

## 故障排除

要解决此错误，您可以：

1. 检查您的提示模板是否正确。使用 f-string 格式时，确保正确转义花括号：
   * 在 f-string 中使用 `{{` 表示单花括号
   * 在 f-string 中使用 `{{{{` 表示双花括号
2. 使用 `MessagesPlaceholder` 组件时，请确认您传递的是消息数组或类似消息的对象。如果使用简写元组，请将变量名用花括号括起来，例如 `["placeholder", "{messages}"]`
3. 通过使用 [LangSmith](/langsmith/home) 或记录日志来检查提示模板的实际输入，以调试并验证它们是否符合预期
4. 如果提示来源于 LangChain [Prompt Hub](https://smith.langchain.com/prompts)，请隔离提示并使用示例输入进行测试，以确保其按预期工作

***

<div className="source-links">
  <Callout icon="terminal-2">
    [将这些文档](/use-these-docs)通过 MCP 连接到 Claude、VSCode 等，以获取实时答案。
  </Callout>

  <Callout icon="edit">
    [在 GitHub 上编辑此页面](https://github.com/langchain-ai/docs/edit/main/src/oss/langchain/errors/INVALID_PROMPT_INPUT.mdx) 或 [提交问题](https://github.com/langchain-ai/docs/issues/new/choose)。
  </Callout>
</div>
