Skip to content

Commit 2882995

Browse files
SanjaySiddharthhangfei
authored andcommitted
fix: Fixes DeprecationWarning when using send method
Merge #3352 Replace send() method with send_realtime_input() to fix DeprecationWarning ### Link to Issue or Description of Change **1. Link to an existing issue (if applicable):** - Closes: #2393 ### Testing Plan Have run unit test for test_live_request_queue.py **Unit Tests:** - [ ] I have added or updated unit tests for my change. - [x] All unit tests pass locally. Summary : tests/unittests/agents/test_live_request_queue.py::test_send_realtime PASSED [100%] **Manual End-to-End (E2E) Tests:** ### Checklist - [x] I have read the [CONTRIBUTING.md](https://github.com/google/adk-python/blob/main/CONTRIBUTING.md) document. - [x] I have performed a self-review of my own code. - [x] I have commented my code, particularly in hard-to-understand areas. - [ ] I have added tests that prove my fix is effective or that my feature works. - [x] New and existing unit tests pass locally with my changes. - [x] I have manually tested my changes end-to-end. - [ ] Any dependent changes have been merged and published in downstream modules. Tested both API variants. Co-authored-by: Hangfei Lin <hangfei@google.com> COPYBARA_INTEGRATE_REVIEW=#3352 from SanjaySiddharth:fix-dep-session.send b23b641 PiperOrigin-RevId: 830182844
1 parent a3b4ec6 commit 2882995

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/google/adk/models/gemini_llm_connection.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,10 @@ async def send_realtime(self, input: RealtimeInput):
106106
input: The input to send to the model.
107107
"""
108108
if isinstance(input, types.Blob):
109-
input_blob = input.model_dump()
110109
# The blob is binary and is very large. So let's not log it.
111110
logger.debug('Sending LLM Blob.')
112-
await self._gemini_session.send(input=input_blob)
111+
await self._gemini_session.send_realtime_input(media=input)
112+
113113
elif isinstance(input, types.ActivityStart):
114114
logger.debug('Sending LLM activity start signal.')
115115
await self._gemini_session.send_realtime_input(activity_start=input)

tests/unittests/models/test_gemini_llm_connection.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,11 @@ async def test_send_realtime_default_behavior(
4545
await gemini_connection.send_realtime(test_blob)
4646

4747
# Should call send once
48-
mock_gemini_session.send.assert_called_once_with(input=test_blob.model_dump())
48+
mock_gemini_session.send_realtime_input.assert_called_once_with(
49+
media=test_blob
50+
)
51+
# Should not call .send function
52+
mock_gemini_session.send.assert_not_called()
4953

5054

5155
@pytest.mark.asyncio

0 commit comments

Comments
 (0)