Class PartConverter
java.lang.Object
com.google.adk.a2a.converters.PartConverter
Utility class for converting between Google GenAI Parts and A2A DataParts.
**EXPERIMENTAL:** Subject to change, rename, or removal in any future patch release. Do not use in production code.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic Optional<io.a2a.spec.DataPart> convertGenaiPartToA2aPart(com.google.genai.types.Part part) Convert a Google GenAI Part to an A2A Part.static Optional<io.a2a.spec.Part<?>> fromGenaiPart(com.google.genai.types.Part part) 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 Optional<com.google.genai.types.Part> toGenaiPart(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_TYPE_FUNCTION_CALL
- See Also:
-
A2A_DATA_PART_METADATA_TYPE_FUNCTION_RESPONSE
- See Also:
-
A2A_DATA_PART_METADATA_TYPE_CODE_EXECUTION_RESULT
- See Also:
-
A2A_DATA_PART_METADATA_TYPE_EXECUTABLE_CODE
- See Also:
-
-
Method Details
-
toTextPart
-
toGenaiPart
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) -
convertGenaiPartToA2aPart
public static Optional<io.a2a.spec.DataPart> convertGenaiPartToA2aPart(com.google.genai.types.Part part) Convert a Google GenAI Part to an A2A Part.- Parameters:
part- The GenAI part to convert.- Returns:
- Optional containing the converted A2A Part, or empty if conversion fails.
-
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
Convert a GenAI part into the A2A JSON representation.
-