Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/google/adk/models/gemini_llm_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,8 @@ async def send_realtime(self, input: RealtimeInput):
input: The input to send to the model.
"""
if isinstance(input, types.Blob):
input_blob = input.model_dump()
logger.debug('Sending LLM Blob: %s', input_blob)
await self._gemini_session.send(input=input_blob)
logger.debug('Sending LLM Blob: %s', input)
await self._gemini_session.send_realtime_input(media=input)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

While this change to use send_realtime_input is correct for handling types.Blob, the associated unit test has not been updated. The test test_send_realtime_default_behavior in tests/unittests/models/test_gemini_llm_connection.py still asserts that mock_gemini_session.send is called, which will now fail.

Please update the test to verify that mock_gemini_session.send_realtime_input is called instead. Here is a suggested update for the test:

@pytest.mark.asyncio
async def test_send_realtime_blob(gemini_connection, mock_gemini_session, test_blob):
  """Test send_realtime with a blob."""
  await gemini_connection.send_realtime(test_blob)

  mock_gemini_session.send_realtime_input.assert_called_once_with(media=test_blob)
  mock_gemini_session.send.assert_not_called()

Failing to update tests alongside code changes can lead to a brittle test suite and hide potential regressions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi ! This is done ! Thanks

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you help explain why we migrate to this method and not others:
("Please use one of the more specific methods: send_client_content, send_realtime_input, or send_tool_response instead.
await self._gemini_session.send(input=input_blob)")

elif isinstance(input, types.ActivityStart):
logger.debug('Sending LLM activity start signal')
await self._gemini_session.send_realtime_input(activity_start=input)
Expand Down