Skip to content

Commit e462cc9

Browse files
committed
pr-5097 ran autoformatter
1 parent 8071903 commit e462cc9

2 files changed

Lines changed: 19 additions & 9 deletions

File tree

src/google/adk/models/gemini_llm_connection.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ async def send_content(self, content: types.Content):
132132
if isinstance(part.text, str):
133133
await self._gemini_session.send_realtime_input(text=part.text)
134134
has_text = True
135-
135+
136136
if not has_text:
137137
logger.warning('Encountered unsupported content in send_content')
138138
else:
@@ -161,9 +161,13 @@ async def send_realtime(self, input: RealtimeInput):
161161
# As of now, Gemini 3.1 Flash Live is only available in Gemini API, not
162162
# Vertex AI.
163163
if is_gemini_31 and is_gemini_api:
164-
if isinstance(input.mime_type, str) and input.mime_type.startswith('audio/'):
164+
if isinstance(input.mime_type, str) and input.mime_type.startswith(
165+
'audio/'
166+
):
165167
await self._gemini_session.send_realtime_input(audio=input)
166-
elif isinstance(input.mime_type, str) and input.mime_type.startswith('image/'):
168+
elif isinstance(input.mime_type, str) and input.mime_type.startswith(
169+
'image/'
170+
):
167171
await self._gemini_session.send_realtime_input(video=input)
168172
else:
169173
logger.warning(
@@ -172,9 +176,13 @@ async def send_realtime(self, input: RealtimeInput):
172176
input.mime_type,
173177
)
174178
else:
175-
if isinstance(input.mime_type, str) and input.mime_type.startswith('video/'):
179+
if isinstance(input.mime_type, str) and input.mime_type.startswith(
180+
'video/'
181+
):
176182
await self._gemini_session.send_realtime_input(video=input)
177-
elif isinstance(input.mime_type, str) and input.mime_type.startswith('audio/'):
183+
elif isinstance(input.mime_type, str) and input.mime_type.startswith(
184+
'audio/'
185+
):
178186
await self._gemini_session.send_realtime_input(audio=input)
179187
else:
180188
await self._gemini_session.send_realtime_input(media=input)

tests/unittests/models/test_gemini_llm_connection.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,11 @@ async def test_send_history(gemini_connection, mock_gemini_session):
112112
@pytest.mark.asyncio
113113
async def test_send_content_text(gemini_connection, mock_gemini_session):
114114
"""Test send_content with text content when audio is inactive.
115-
115+
116116
Note: gemini_connection._audio_active is False by default.
117117
"""
118118
assert gemini_connection._audio_active is False
119-
119+
120120
content = types.Content(
121121
role='user', parts=[types.Part.from_text(text='Hello')]
122122
)
@@ -131,10 +131,12 @@ async def test_send_content_text(gemini_connection, mock_gemini_session):
131131

132132

133133
@pytest.mark.asyncio
134-
async def test_send_content_text_audio_active(gemini_connection, mock_gemini_session):
134+
async def test_send_content_text_audio_active(
135+
gemini_connection, mock_gemini_session
136+
):
135137
"""Test send_content routes to send_realtime_input when audio is active."""
136138
gemini_connection._audio_active = True
137-
139+
138140
content = types.Content(
139141
role='user', parts=[types.Part.from_text(text='Hello')]
140142
)

0 commit comments

Comments
 (0)