Skip to content

Commit c03129b

Browse files
agilyolyolagillkawka
authored
fix(grpc): Add extensions to Artifact converters. (#523)
# Description Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly: - [ ] Follow the [`CONTRIBUTING` Guide](https://github.com/a2aproject/a2a-python/blob/main/CONTRIBUTING.md). - [ ] Make your Pull Request title in the <https://www.conventionalcommits.org/> specification. - Important Prefixes for [release-please](https://github.com/googleapis/release-please): - `fix:` which represents bug fixes, and correlates to a [SemVer](https://semver.org/) patch. - `feat:` represents a new feature, and correlates to a SemVer minor. - `feat!:`, or `fix!:`, `refactor!:`, etc., which represent a breaking change (indicated by the `!`) and will result in a SemVer major. - [ ] Ensure the tests and linter pass (Run `bash scripts/format.sh` from the repository root to format) - [ ] Appropriate docs were updated (if necessary) Fixes #<issue_number_goes_here> 🦕 --------- Co-authored-by: yolagil <agil@peotic.com> Co-authored-by: Lukasz Kawka <luk.kawka@gmail.com>
1 parent 265fd33 commit c03129b

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/a2a/utils/proto_utils.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def make_dict_serializable(value: Any) -> Any:
5757
Returns:
5858
A serializable value.
5959
"""
60-
if isinstance(value, (str, int, float, bool)) or value is None:
60+
if isinstance(value, str | int | float | bool) or value is None:
6161
return value
6262
if isinstance(value, dict):
6363
return {k: make_dict_serializable(v) for k, v in value.items()}
@@ -140,6 +140,7 @@ def message(cls, message: types.Message | None) -> a2a_pb2.Message | None:
140140
task_id=message.task_id or '',
141141
role=cls.role(message.role),
142142
metadata=cls.metadata(message.metadata),
143+
extensions=message.extensions or [],
143144
)
144145

145146
@classmethod
@@ -239,6 +240,7 @@ def artifact(cls, artifact: types.Artifact) -> a2a_pb2.Artifact:
239240
metadata=cls.metadata(artifact.metadata),
240241
name=artifact.name,
241242
parts=[cls.part(p) for p in artifact.parts],
243+
extensions=artifact.extensions or [],
242244
)
243245

244246
@classmethod
@@ -695,6 +697,7 @@ def artifact(cls, artifact: a2a_pb2.Artifact) -> types.Artifact:
695697
metadata=cls.metadata(artifact.metadata),
696698
name=artifact.name,
697699
parts=[cls.part(p) for p in artifact.parts],
700+
extensions=artifact.extensions or None,
698701
)
699702

700703
@classmethod

0 commit comments

Comments
 (0)