Skip to content

SQL AI Agent 节点(SQL AI Agent node)#

功能已移除

n8n 在 2025 年 2 月移除了此功能。

SQL代理使用SQL数据库作为数据源。它可以理解自然语言问题,将其转换为SQL查询,执行查询,并以用户友好的格式呈现结果。这个代理对于构建数据库的自然语言界面非常有价值。

🌐 The SQL Agent uses a SQL database as a data source. It can understand natural language questions, convert them into SQL queries, execute the queries, and present the results in a user-friendly format. This agent is valuable for building natural language interfaces to databases.

有关 AI Agent 节点本身的更多信息,请参考 AI Agent

🌐 Refer to AI Agent for more information on the AI Agent node itself.

节点参数(Node parameters)#

使用以下参数配置 SQL Agent。

🌐 Configure the SQL Agent using the following parameters.

数据源(Data Source)#

选择用作节点数据源的数据库。选项包括:

🌐 Choose the database to use as a data source for the node. Options include:

  • MySQL:选择此选项以使用 MySQL 数据库。
    • 还要选择 MySQL 凭证
  • SQLite:选择此选项以使用 SQLite 数据库。
    • 你必须在 Agent 之前添加一个 从磁盘读取/写入文件 节点,以读取你的 SQLite 文件。
    • 还要输入来自“从磁盘读取/写入文件”节点的 SQLite 文件的输入二进制字段名称。
  • Postgres:选择此选项以使用 Postgres 数据库。
    • 还要选择 Postgres 的凭证

Postgres 和 MySQL 代理

如果你正在使用 PostgresMySQL,该代理不支持凭证隧道选项。

提示(Prompt)#

Select how you want the node to construct the prompt (also known as the user's query or input from the chat).

Choose from:

  • Take from previous node automatically: If you select this option, the node expects an input from a previous node called chatInput.
  • Define below: If you select this option, provide either static text or an expression for dynamic content to serve as the prompt in the Prompt (User Message) field.

节点选项(Node options)#

使用以下选项优化 SQL 代理节点的行为:

🌐 Refine the SQL Agent node's behavior using these options:

已忽略表格(Ignored Tables)#

如果你希望节点忽略数据库中的某些表,请输入以逗号分隔的表列表,以表明你希望节点忽略这些表。

🌐 If you'd like the node to ignore any tables from the database, enter a comma-separated list of tables you'd like it to ignore.

如果留空,代理不会忽略任何表。

🌐 If left empty, the agent doesn't ignore any tables.

包含示例行(Include Sample Rows)#

输入要包含在提示给代理中的示例行数。默认值为 3

🌐 Enter the number of sample rows to include in the prompt to the agent. Default is 3.

示例行有助于代理理解数据库架构,但也会增加使用的令牌数量。

🌐 Sample rows help the agent understand the schema of the database, but they also increase the number of tokens used.

包含表格(Included Tables)#

如果你只想包含数据库中的特定表,请输入以逗号分隔的表列表。

🌐 If you'd only like to include specific tables from the database, enter a comma-separated list of tables to include.

如果留空,代理将包含所有表。

🌐 If left empty, the agent includes all tables.

提示前缀(Prefix Prompt)#

提示文本之前输入你想发送给代理的信息。此初始信息可以为代理提供更多上下文和指导,说明它可以做什么和不能做什么,以及如何格式化回复。

🌐 Enter a message you'd like to send to the agent before the Prompt text. This initial message can provide more context and guidance to the agent about what it can and can't do, and how to format the response.

n8n 会在此字段中填充一个示例。

🌐 n8n fills this field with an example.

后缀提示(Suffix Prompt)#

Prompt 文本之后输入你想发送给代理的消息。

🌐 Enter a message you'd like to send to the agent after the Prompt text.

可用的 LangChain 表达式:

🌐 Available LangChain expressions:

  • {chatHistory}:此对话中的消息历史,有助于保持上下文。
  • {input}:包含用户提示。
  • {agent_scratchpad}:需要在下一次迭代中记住的信息。

n8n 会在此字段中填充一个示例。

🌐 n8n fills this field with an example.

限制(Limit)#

请输入要返回的最大结果数。

🌐 Enter the maximum number of results to return.

默认是 10

🌐 Default is 10.

模板和示例(Templates and examples)#

请参阅主 AI 代理节点的 模板和示例 部分。

🌐 Refer to the main AI Agent node's Templates and examples section.

常见问题(Common issues)#

有关常见问题或问题及建议的解决方案,请参阅 常见问题

🌐 For common questions or issues and suggested solutions, refer to Common issues.