Class PartConverter

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

public final class PartConverter extends Object
Utility class for converting between Google GenAI Parts and A2A DataParts.
  • Field Details

  • 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)
      Convert an A2A JSON part into a Google GenAI part representation.
    • 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)
      Converts an A2A Message to a Google GenAI Content object.
      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)
      Convert a GenAI part into the A2A JSON representation.
    • remoteCallAsUserPart

      public static com.google.genai.types.Part remoteCallAsUserPart(String author, com.google.genai.types.Part part)
      Converts a remote call part to a user part.

      Events are rephrased as if a user was telling what happened in the session up to the point. E.g.

      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.