`Class PartConverter`

java.lang.Object
com.google.adk.a2a.converters.PartConverter

public final class PartConverter extends Object
这是一个实用类,用于在 Google GenAI 的数据结构(Parts)与 A2A(All-to-All)的数据结构(DataParts)之间进行转换。
  • 字段详情

  • 方法详细信息(Method Details)

    • toTextPart

      public static Optional<io.a2a.spec.TextPart> toTextPart(io.a2a.spec.Part<?> part)
    • toGenaiPart

      public static com.google.genai.types.Part toGenaiPart(io.a2a.spec.Part<?> a2aPart)
      将 A2A 格式的 JSON 数据转换为 Google GenAI 格式的表示形式。
    • toGenaiParts

      public static com.google.common.collect.ImmutableList<com.google.genai.types.Part> toGenaiParts(List<io.a2a.spec.Part<?>> a2aParts)
    • messageToContent

      public static com.google.genai.types.Content messageToContent(io.a2a.spec.Message message)
      将 A2A 消息转换为 Google GenAI 内容对象。
      Parameters:
      message - The A2A Message to convert.
      Returns:
      The converted Google GenAI Content object.
    • fromGenaiPart

      public static io.a2a.spec.Part<?> fromGenaiPart(com.google.genai.types.Part part, boolean isPartial)
      将 GenAI 的某个部分转换为 A2A 格式的 JSON 表示形式。
    • remoteCallAsUserPart

      public static com.google.genai.types.Part remoteCallAsUserPart(String author, com.google.genai.types.Part part)
      将远程调用部分转换为用户操作部分。

      事件的描述方式被重新调整了,仿佛是在让用户自己讲述在会话进行到当前这个阶段之前发生了什么。 例如:

      For context:
      User said: Now help me with Z
      Agent A said: Agent B can help you with it!
      Agent B said: Agent C might know better.*
      
      Parameters:
      author - The author of the part.
      part - The part to convert.
      Returns:
      The converted part.