MessageConvertUtil
public class MessageConvertUtil
源码Source
io/agentscope/core/a2a/agent/utils/MessageConvertUtil.java:40–279消息转换 Util,支持智能体之间的发现、委派与协作。位于 io.agentscope.core.a2a.agent.utils 包。核心成员包括 convertFromArtifact、convertFromMessage、convertFromMsg、buildTypeMetadata。
Message Converter between Agentscope Msg and A2A Message or Artifact.
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public static Msg convertFromArtifact(Artifact artifact, String agentName)static | 转换 `convertFromArtifact`。 Convert a single `Artifact` to `Msg`. |
public static Msg convertFromArtifact(List<Artifact> artifacts, String agentName)static | 转换列出的`Artifact`到`Msg`。 Convert a list of `Artifact` to `Msg`. |
public static Msg convertFromMessage(Message message, String agentName)static | 转换来自消息。 Convert a single `Message` to `Msg`. |
public static Message convertFromMsg(List<Msg> msgs)static | 转换列出的`Msg`到`Message`。 Convert a list of `Msg` to `Message`. |
public static Map<String, Object> buildTypeMetadata(String type)static | 构建元数据使用内容块类型 in`Part`。 Build metadata with content block type in `Part`. |
方法详情Method Detail
convertFromArtifact
public static Msg convertFromArtifact(Artifact artifact, String agentName)
static
转换 convertFromArtifact。
Convert a single Artifact to Msg.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
artifact | Artifact | artifact(类型 `Artifact`)。the artifact to convert |
agentName | String | 智能体名称(类型 `String`)。the name of the agent that generated the artifact |
Msg已转换消息对象。the converted Msg object
源码Source
io/agentscope/core/a2a/agent/utils/MessageConvertUtil.java:54–56convertFromArtifact
public static Msg convertFromArtifact(List<Artifact> artifacts, String agentName)
static
转换列出的Artifact到Msg。
Convert a list of Artifact to Msg.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
artifacts | List<Artifact> | artifacts(类型 `List`)。the list of artifacts to convert |
agentName | String | 智能体名称(类型 `String`)。the name of the agent that generated the artifacts |
Msg已转换消息对象。the converted Msg object
源码Source
io/agentscope/core/a2a/agent/utils/MessageConvertUtil.java:65–81convertFromMessage
public static Msg convertFromMessage(Message message, String agentName)
static
转换来自消息。
Convert a single Message to Msg.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
message | Message | 消息到转换。the message to convert |
agentName | String | 智能体名称(类型 `String`)。the name of the agent that generated the message |
Msg已转换消息对象。the converted Msg object
源码Source
io/agentscope/core/a2a/agent/utils/MessageConvertUtil.java:90–98convertFromMsg
public static Message convertFromMsg(List<Msg> msgs)
static
转换列出的Msg到Message。
Convert a list of Msg to Message.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
msgs | List<Msg> | 消息到转换的列出。the list of Msg to convert |
Message已转换消息对象。the converted Message object
源码Source
io/agentscope/core/a2a/agent/utils/MessageConvertUtil.java:106–145buildTypeMetadata
public static Map<String, Object> buildTypeMetadata(String type)
static
构建元数据使用内容块类型 inPart。
Build metadata with content block type in Part.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
type | String | 类型(类型 `String`)。the content block type, see `ContentBlock`. |
Map<String, Object>返回映射。metadata with content block type.
源码Source
io/agentscope/core/a2a/agent/utils/MessageConvertUtil.java:274–278