|
12 | 12 | import httpx |
13 | 13 | from a2a.types import Message |
14 | 14 | from opentelemetry.propagate import inject |
15 | | - |
16 | | -from google.protobuf.json_format import MessageToDict as _proto_message_to_dict |
17 | | -from google.protobuf.json_format import ParseDict as _proto_parse_dict |
18 | | - |
19 | 15 | from pydantic_core import ValidationError |
20 | 16 |
|
21 | 17 | from sap_cloud_sdk.core.telemetry import Module, Operation |
@@ -381,7 +377,7 @@ def call_hook( |
381 | 377 | .get("main", [[{}]])[0][0] |
382 | 378 | .get("json", {}) |
383 | 379 | ) |
384 | | - return _proto_parse_dict(response_json, Message()) |
| 380 | + return Message(**response_json) |
385 | 381 | except (KeyError, IndexError, TypeError, ValidationError) as exc: |
386 | 382 | raise ExtensibilityError( |
387 | 383 | f"Failed to extract response from last executed node: {exc}" |
@@ -450,10 +446,7 @@ async def _execute_workflow_via_agw( |
450 | 446 | message: Optional[Any], |
451 | 447 | headers: Optional[dict], |
452 | 448 | ) -> tuple[str, Any]: |
453 | | - if message is None: |
454 | | - message_body: dict = {} |
455 | | - else: |
456 | | - message_body = _proto_message_to_dict(message, preserving_proto_field_name=True) |
| 449 | + message_body = message.model_dump(mode="json") if message is not None else {} |
457 | 450 | execute_arguments = { |
458 | 451 | "workflowId": hook.n8n_workflow_config.workflow_id, |
459 | 452 | "inputs": { |
@@ -507,7 +500,7 @@ def _extract_message(data: dict) -> Message: |
507 | 500 | .get("main", [[{}]])[0][0] |
508 | 501 | .get("json", {}) |
509 | 502 | ) |
510 | | - return _proto_parse_dict(response_json, Message()) |
| 503 | + return Message(**response_json) |
511 | 504 | except (KeyError, IndexError, TypeError, ValidationError) as exc: |
512 | 505 | raise TransportError( |
513 | 506 | f"Failed to extract response from last executed node: {exc}" |
|
0 commit comments