Class PartConverter
java.lang.Object
com.google.adk.a2a.converters.PartConverter
Utility class for converting between Google GenAI Parts and A2A DataParts.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final String -
Method Summary
Modifier and TypeMethodDescriptionstatic io.a2a.spec.Part<?> fromGenaiPart(com.google.genai.types.Part part, boolean isPartial) Convert a GenAI part into the A2A JSON representation.static com.google.genai.types.ContentmessageToContent(io.a2a.spec.Message message) Converts an A2A Message to a Google GenAI Content object.static com.google.genai.types.PartremoteCallAsUserPart(String author, com.google.genai.types.Part part) Converts a remote call part to a user part.static com.google.genai.types.ParttoGenaiPart(io.a2a.spec.Part<?> a2aPart) Convert an A2A JSON part into a Google GenAI part representation.static com.google.common.collect.ImmutableList<com.google.genai.types.Part> toGenaiParts(List<io.a2a.spec.Part<?>> a2aParts) static Optional<io.a2a.spec.TextPart> toTextPart(io.a2a.spec.Part<?> part)
-
Field Details
-
A2A_DATA_PART_METADATA_TYPE_KEY
- See Also:
-
A2A_DATA_PART_METADATA_IS_LONG_RUNNING_KEY
- See Also:
-
A2A_DATA_PART_METADATA_IS_PARTIAL_KEY
- See Also:
-
LANGUAGE_KEY
- See Also:
-
OUTCOME_KEY
- See Also:
-
CODE_KEY
- See Also:
-
OUTPUT_KEY
- See Also:
-
NAME_KEY
- See Also:
-
ARGS_KEY
- See Also:
-
RESPONSE_KEY
- See Also:
-
ID_KEY
- See Also:
-
WILL_CONTINUE_KEY
- See Also:
-
PARTIAL_ARGS_KEY
- See Also:
-
SCHEDULING_KEY
- See Also:
-
PARTS_KEY
- See Also:
-
-
Method Details
-
toTextPart
-
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.
-