组装消息节点
概述
组装消息节点(Assemble Message Node)旨在将多个部分组合成一条聊天消息。它类似于提示节点(Prompt Node),但适用于多模态模型,允许您在消息中同时包含文本和图像。当使用能同时处理文本和图像的多模态LLM(如GPT-4 Vision)时,该节点特别有用。
Assemble Message节点可以与Image Node或URL Reference Node配合使用,在消息中包含图片。
Assemble Message节点输出的聊天消息格式与Prompt Node相同。
- 输入
- 输出
- 编辑器设置
输入项
标题 | 数据类型 | 描述 | 默认值 | 备注 |
---|---|---|---|---|
Part N | string /string[] /image /image[] | A part of the message to assemble. Arrays connected to inputs will be flattened, so connecting a single image[] connection will put multiple images into the message. | N/A | Dynamic number of input ports based on how many inputs are already connected to the node. |
输出
标题 | 数据类型 | 描述 | 备注 |
---|---|---|---|
Message | chat-message | The assembled chat message. The message will be in the same format as a message from a Prompt Node. | The output will be a chat message containing the assembled data. The type of the message will be the specified type. |
编辑器设置
设置 | 描述 | 默认值 | 使用输入切换 | 输入数据类型 |
---|---|---|---|---|
Type | The type of message to assemble. The value should be either 'system', 'user', 'assistant', or 'function'. | 'user' | Yes | string |
示例1:组装包含文本和图片的用户消息
- 创建一个Assemble Message节点并将类型设置为'user'。
- 创建一个文本节点并将其值设为"这里是一张图片:"。将文本节点的输出连接到组装消息节点的第一个输入。
- 创建一个Image Node并浏览选择您的图像。将Image Node的输出连接到Assemble Message Node的第二个输入端口。
- 运行图形。Assemble Message节点的
Message
输出应包含一条用户消息,文本为"这是一张猫的图片:"以及(Image)
文本,表示消息中包含一张图片。
错误处理
如果启用了Type
输入并将其设置为无效值,Assemble Message Node将会报错。
常见问题
问:我可以在一条消息中包含多张图片吗?
A: 是的,您可以通过连接多个输入节点在一条消息中包含多张图片。
问:我可以在函数工具调用中使用Assemble Message Node吗?
A: 是的,您可以将类型(Type)设置为'function'来组装一个函数响应工具调用消息。请注意,函数工具调用消息需要一个工具调用ID(Tool Call ID),可以通过Tool Call ID
输入或设置提供。工具调用的输出是组装好的消息内容。
问:我可以在assistant
类型的消息中包含函数调用吗?
A: 目前只有Prompt Node支持通过assistant
类型的消息进行函数/工具调用。