Skip to content

Commit e5adaa1

Browse files
committed
adress review comments: rename notif & reverted elifs
1 parent 957162d commit e5adaa1

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

examples/google_adk/birthday_planner/adk_agent_executor.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
import asyncio
22
import logging
3-
4-
from collections.abc import AsyncGenerator, AsyncIterable
5-
from typing import Any
3+
from collections.abc import AsyncGenerator
4+
from typing import Any, AsyncIterable
65
from uuid import uuid4
76

87
import httpx
9-
108
from google.adk import Runner
119
from google.adk.agents import LlmAgent, RunConfig
1210
from google.adk.artifacts import InMemoryArtifactService
@@ -44,7 +42,6 @@
4442
from a2a.utils import get_text_parts
4543
from a2a.utils.errors import ServerError
4644

47-
4845
logger = logging.getLogger(__name__)
4946
logger.setLevel(logging.DEBUG)
5047

@@ -69,7 +66,7 @@ def __init__(self, calendar_agent_url):
6966
name='birthday_planner_agent',
7067
description='An agent that helps manage birthday parties.',
7168
after_tool_callback=self._handle_auth_required_task,
72-
instruction="""
69+
instruction=f"""
7370
You are an agent that helps plan birthday parties.
7471
7572
Your job as a party planner is to act as a sounding board and idea generator for
@@ -168,7 +165,7 @@ async def _process_request(
168165
task_updater.add_artifact(response)
169166
task_updater.complete()
170167
break
171-
if calls := event.get_function_calls():
168+
elif calls := event.get_function_calls():
172169
for call in calls:
173170
# Provide an update on what we're doing.
174171
if call.name == 'message_calendar_agent':
@@ -317,21 +314,23 @@ def convert_a2a_part_to_genai(part: Part) -> types.Part:
317314
part = part.root
318315
if isinstance(part, TextPart):
319316
return types.Part(text=part.text)
320-
if isinstance(part, FilePart):
317+
elif isinstance(part, FilePart):
321318
if isinstance(part.file, FileWithUri):
322319
return types.Part(
323320
file_data=types.FileData(
324321
file_uri=part.file.uri, mime_type=part.file.mime_type
325322
)
326323
)
327-
if isinstance(part.file, FileWithBytes):
324+
elif isinstance(part.file, FileWithBytes):
328325
return types.Part(
329326
inline_data=types.Blob(
330327
data=part.file.bytes, mime_type=part.file.mime_type
331328
)
332329
)
333-
raise ValueError(f'Unsupported file type: {type(part.file)}')
334-
raise ValueError(f'Unsupported part type: {type(part)}')
330+
else:
331+
raise ValueError(f'Unsupported file type: {type(part.file)}')
332+
else:
333+
raise ValueError(f'Unsupported part type: {type(part)}')
335334

336335

337336
def convert_genai_parts_to_a2a(parts: list[types.Part]) -> list[Part]:
@@ -347,14 +346,14 @@ def convert_genai_part_to_a2a(part: types.Part) -> Part:
347346
"""Convert a single Google GenAI Part type into an A2A Part type."""
348347
if part.text:
349348
return TextPart(text=part.text)
350-
if part.file_data:
349+
elif part.file_data:
351350
return FilePart(
352351
file=FileWithUri(
353352
uri=part.file_data.file_uri,
354353
mime_type=part.file_data.mime_type,
355354
)
356355
)
357-
if part.inline_data:
356+
elif part.inline_data:
358357
return Part(
359358
root=FilePart(
360359
file=FileWithBytes(
@@ -363,4 +362,5 @@ def convert_genai_part_to_a2a(part: types.Part) -> Part:
363362
)
364363
)
365364
)
366-
raise ValueError(f'Unsupported part type: {part}')
365+
else:
366+
raise ValueError(f'Unsupported part type: {part}')

tests/server/request_handlers/test_jsonrpc_handler.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ async def streaming_coro():
390390
mock_agent_executor.execute.assert_called_once()
391391
assert mock_task.history is not None and len(mock_task.history) == 1
392392

393-
async def test_set_push_notif_success(self) -> None:
393+
async def test_set_push_notification_success(self) -> None:
394394
mock_agent_executor = AsyncMock(spec=AgentExecutor)
395395
mock_task_store = AsyncMock(spec=TaskStore)
396396
mock_push_notifier = AsyncMock(spec=PushNotifier)
@@ -425,7 +425,7 @@ async def test_set_push_notif_success(self) -> None:
425425
mock_task.id, task_push_config.pushNotificationConfig
426426
)
427427

428-
async def test_get_push_notif_success(self) -> None:
428+
async def test_get_push_notification_success(self) -> None:
429429
mock_agent_executor = AsyncMock(spec=AgentExecutor)
430430
mock_task_store = AsyncMock(spec=TaskStore)
431431
mock_httpx_client = AsyncMock(spec=httpx.AsyncClient)
@@ -463,7 +463,7 @@ async def test_get_push_notif_success(self) -> None:
463463
)
464464
assert get_response.root.result == task_push_config # type: ignore
465465

466-
async def test_on_message_stream_new_message_send_push_notif_success(
466+
async def test_on_message_stream_new_message_send_push_notification_success(
467467
self,
468468
) -> None:
469469
mock_agent_executor = AsyncMock(spec=AgentExecutor)

0 commit comments

Comments
 (0)