MessageConvertUtil
public class MessageConvertUtil
源码Source
io/agentscope/core/a2a/server/utils/MessageConvertUtil.java:44–326消息转换 Util,支持智能体之间的发现、委派与协作。位于 io.agentscope.core.a2a.server.utils 包。核心成员包括 convertFromMsgToMessage、compactStreamingChunks、convertFromContentBlocks、convertFromMessageToMsgs。
Message Converter between Agentscope Msg and A2A Message or Artifact.
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public static Message convertFromMsgToMessage(List<Msg> msgs, String taskId, String contextId)static | 转换列出的`Msg`到`Message`。 Convert a list of `Msg` to `Message`. |
public static List<Msg> compactStreamingChunks(List<Msg> msgs)static | 设置该参数。 Compact consecutive streaming delta messages that share the same message id. |
public static Message convertFromMsgToMessage(Msg msg, String taskId, String contextId)static | 转换`Msg`到`Message`。 Convert a `Msg` to `Message`. |
public static List<Part<?>> convertFromContentBlocks(Msg msg)static | 转换 `convertFromContentBlocks`。 Convert content blocks in `Msg` to list of `Part`. |
public static List<Part<?>> convertFromContentBlocks(Msg msg, boolean streamingChunk)static | 转换 `convertFromContentBlocks`。 Convert content blocks in `Msg` to list of `Part`. |
public static List<Msg> convertFromMessageToMsgs(Message message)static | 转换A2A`Message`到列出的`Msg`。 Convert a A2A `Message` to List of `Msg`. |
方法详情Method Detail
convertFromMsgToMessage
public static Message convertFromMsgToMessage(List<Msg> msgs, String taskId, String contextId)
static
转换列出的Msg到Message。
Convert a list of Msg to Message.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
msgs | List<Msg> | 消息到转换的列出。the list of Msg to convert |
taskId | String | 任务标识(类型 `String`)。the taskId |
contextId | String | 上下文标识(类型 `String`)。the contextId |
Message已转换消息对象。the converted Message object
源码Source
io/agentscope/core/a2a/server/utils/MessageConvertUtil.java:59–62compactStreamingChunks
public static List<Msg> compactStreamingChunks(List<Msg> msgs)
static
设置该参数。
Compact consecutive streaming delta messages that share the same message id.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
msgs | List<Msg> | 消息列表(类型 `List`)。messages emitted by the streaming event pipeline |
List<Msg>返回列出。messages with consecutive text/thinking deltas merged per message id
源码Source
io/agentscope/core/a2a/server/utils/MessageConvertUtil.java:74–98convertFromMsgToMessage
public static Message convertFromMsgToMessage(Msg msg, String taskId, String contextId)
static
转换Msg到Message。
Convert a Msg to Message.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
msg | Msg | 消息到转换。the Msg to convert |
taskId | String | 任务标识(类型 `String`)。the taskId |
contextId | String | 上下文标识(类型 `String`)。the contextId |
Message已转换消息对象。the converted Message object
源码Source
io/agentscope/core/a2a/server/utils/MessageConvertUtil.java:108–120convertFromContentBlocks
public static List<Part<?>> convertFromContentBlocks(Msg msg)
static
转换 convertFromContentBlocks。
Convert content blocks in Msg to list of Part.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
msg | Msg | 消息(类型 `Msg`)。the Msg saved content blocks to convert |
List<Part<?>>片段的列出。list of Part
源码Source
io/agentscope/core/a2a/server/utils/MessageConvertUtil.java:128–130convertFromContentBlocks
public static List<Part<?>> convertFromContentBlocks(Msg msg, boolean streamingChunk)
static
转换 convertFromContentBlocks。
Convert content blocks in Msg to list of Part.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
msg | Msg | 消息(类型 `Msg`)。the Msg saved content blocks to convert |
streamingChunk | boolean | 流式分块(类型 `boolean`)。whether these parts represent streaming delta chunks |
List<Part<?>>片段的列出。list of Part
源码Source
io/agentscope/core/a2a/server/utils/MessageConvertUtil.java:139–160convertFromMessageToMsgs
public static List<Msg> convertFromMessageToMsgs(Message message)
static
转换A2AMessage到列出的Msg。
Convert a A2A Message to List of Msg.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
message | Message | 消息(类型 `Message`)。a2a protocol message from a2a client. |
List<Msg>`Msg`的列出。list of `Msg`
源码Source
io/agentscope/core/a2a/server/utils/MessageConvertUtil.java:229–270