Skip to content

聊天内存管理器节点(Chat Memory Manager node)#

聊天记忆管理节点用于管理工作流中的聊天消息记忆。使用此节点可以在内存中的向量存储中加载、插入和删除聊天消息。

🌐 The Chat Memory Manager node manages chat message memories within your workflows. Use this node to load, insert, and delete chat messages in an in-memory vector store.

This node is useful when you:

  • Can't add a memory node directly.
  • Need to do more complex memory management, beyond what the memory nodes offer. For example, you can add this node to check the memory size of the Agent node's response, and reduce it if needed.
  • Want to inject messages to the AI that look like user messages, to give the AI more context.

本页面列出了聊天内存管理器节点支持的操作列表以及更多资源的链接。

🌐 On this page, you'll find a list of operations that the Chat Memory Manager node supports, along with links to more resources.

Parameter resolution in sub-nodes

Sub-nodes behave differently to other nodes when processing multiple items using an expression.

Most nodes, including root nodes, take any number of items as input, process these items, and output the results. You can use expressions to refer to input items, and the node resolves the expression for each item in turn. For example, given an input of five name values, the expression {{ $json.name }} resolves to each name in turn.

In sub-nodes, the expression always resolves to the first item. For example, given an input of five name values, the expression {{ $json.name }} always resolves to the first name.

节点参数(Node parameters)#

  • 操作模式:在获取多条消息插入消息删除消息操作之间进行选择。
  • 插入模式:在插入消息模式下可用。可选择:
    • 插入消息:在现有消息旁插入消息。
    • 覆盖所有消息:替换当前内存。
  • 删除模式:在删除消息模式下可用。可选择:
    • 最后 N 条:删除最后 N 条消息。
    • 所有消息:从内存中删除消息。
  • 聊天消息:在插入消息模式下可用。定义要插入到记忆中的聊天消息,包括:
    • 类型名称或 ID:设置消息类型。选择以下之一:
      • AI:用于 AI 的消息。
      • 系统:添加一条包含 AI 指令的消息。
      • 用户:用于来自用户的消息。这种消息类型在其他人工智能工具和指南中有时被称为“人类”消息。
    • 消息:输入消息内容。
    • 在聊天中隐藏消息:选择 n8n 是否应在聊天界面向用户显示该消息(关闭表示显示,开启表示隐藏)。
  • 消息数量:在选择 最后 N 条 时,删除消息 模式下可用。输入要删除的最新消息数量。
  • 简化输出:在 获取多条消息 模式下可用。开启后,输出将简化为仅包含发送者(AI、用户或系统)和文本。

模板和示例(Templates and examples)#

Template widget placeholder.

有关该服务的更多信息,请参阅 LangChain 的内存文档

🌐 Refer to LangChain's Memory documentation for more information about the service.

View n8n's Advanced AI documentation.