Skip to content

OpenAI 函数代理节点#

使用 OpenAI 函数代理节点来调用 OpenAI 函数模型。这些模型能够检测何时应该调用函数,并返回应传递给该函数的输入参数。

关于 AI 代理节点本身的更多信息,请参考 AI 代理

您可以将此代理与 Chat Trigger 节点配合使用。附加一个 memory 子节点,以便用户可以进行持续的多轮对话。注意:会话间的记忆不会持久保存。

必须使用 OpenAI 聊天模型

此代理必须配合 OpenAI 聊天模型使用。

节点参数#

使用以下参数配置 OpenAI 函数代理:

提示语#

选择节点如何构建提示词(也称为用户的查询或聊天输入)。

可选方式:

  • 自动从上一节点获取:选择此选项时,节点会从名为 chatInput 的上一节点获取输入。
  • 自定义定义:选择此选项时,在提示词(用户消息)字段中提供静态文本或动态表达式作为提示内容。

要求特定输出格式#

此参数控制节点是否需要特定的输出格式。当启用时,n8n 会提示您连接以下输出解析器之一到该节点:

节点选项#

通过这些选项微调 OpenAI 函数代理节点的行为:

系统消息#

如果您希望在对话开始前向代理发送消息,请输入您想要发送的内容。

此选项可用于引导代理的决策过程。

最大迭代次数#

输入模型应运行的次数,用于尝试从用户提示中生成优质回答。

默认值为 10

返回中间步骤#

选择是否在最终输出中包含智能体(agent)采取的中间步骤(开启)或不包含(关闭)。

这对于根据智能体采取的操作步骤进一步优化其行为非常有用。

模板和示例#

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

常见问题#

关于常见问题或错误及其解决方案,请参阅常见问题

AI glossary#

  • completion: Completions are the responses generated by a model like GPT.
  • hallucinations: Hallucination in AI is when an LLM (large language model) mistakenly perceives patterns or objects that don't exist.
  • vector database: A vector database stores mathematical representations of information. Use with embeddings and retrievers to create a database that your AI can access when answering questions.
  • vector store: A vector store, or vector database, stores mathematical representations of information. Use with embeddings and retrievers to create a database that your AI can access when answering questions.