a2aproject/a2a-python

[Feat]: get_data_parts as part of utils

andrewn3 opened this issue · 0 comments

Is your feature request related to a problem? Please describe.

in message.py under utils there is a get_text_parts() but no equivalent function for data e.g. get_data_parts()

Describe the solution you'd like

e.g.

def get_data_parts(parts: list[Part]) -> list[dict[str, Any]]:
    """Extracts dictionary data from all DataPart objects in a list of Parts.

    Args:
        parts: A list of `Part` objects from a message.

    Returns:
        A list of dictionaries containing the data from any `DataPart` objects found.
    """
    # This line is the key: it looks for DataPart and gets the .data attribute
    return [part.root.data for part in parts if isinstance(part.root, DataPart)]

Describe alternatives you've considered

obviously write an maintain my own function, but if the message structure changes best if it's part of the library.

Additional context

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct