Skip to content

Commit 70c5fc8

Browse files
wuliang229copybara-github
authored andcommitted
refactor(live): Use send_tool_response for function responses
The Gemini session now has a dedicated `send_tool_response` method, which is used instead of wrapping function responses in a `LiveClientToolResponse` and calling `send`. `send` is deprecated. Co-authored-by: Liang Wu <wuliang@google.com> PiperOrigin-RevId: 899796634
1 parent 8bc5728 commit 70c5fc8

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

src/google/adk/models/gemini_llm_connection.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,8 @@ async def send_content(self, content: types.Content):
105105
# All parts have to be function responses.
106106
function_responses = [part.function_response for part in content.parts]
107107
logger.debug('Sending LLM function response: %s', function_responses)
108-
await self._gemini_session.send(
109-
input=types.LiveClientToolResponse(
110-
function_responses=function_responses
111-
),
108+
await self._gemini_session.send_tool_response(
109+
function_responses=function_responses
112110
)
113111
else:
114112
logger.debug('Sending LLM new content %s', content)

tests/unittests/models/test_gemini_llm_connection.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,10 @@ async def test_send_content_function_response(
118118

119119
await gemini_connection.send_content(content)
120120

121-
mock_gemini_session.send.assert_called_once()
122-
call_args = mock_gemini_session.send.call_args[1]
123-
assert 'input' in call_args
124-
assert call_args['input'].function_responses == [function_response]
121+
mock_gemini_session.send_tool_response.assert_called_once()
122+
call_args = mock_gemini_session.send_tool_response.call_args[1]
123+
assert 'function_responses' in call_args
124+
assert call_args['function_responses'] == [function_response]
125125

126126

127127
@pytest.mark.asyncio

0 commit comments

Comments
 (0)