feat: Granular Per Agent Speech Configuration

Merge https://github.com/google/adk-python/pull/3170

Addresses Feature Request: #3116

This PR adds a `speech_config` to the **LLM Agent configuration** for the **live use case**. When an **asynchronous LLM** call is made to the **Gemini Live API**, it prioritizes the most specific agent configuration's speech_config. If that is null, it then uses the run configuration's speech_config. Unit tests have been added to verify this behavior.

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/3170 from qyuo:bidi_agent_speech_config af1bd277d4f95c4a7d9aa0b16828ba3de826ce08
PiperOrigin-RevId: 822305427
This commit is contained in:
Luis Pabon
2025-10-21 15:44:00 -07:00
committed by Copybara-Service
parent 2a901d12f4
commit 409df1378f
4 changed files with 229 additions and 3 deletions
+4 -1
View File
@@ -35,7 +35,10 @@ class StreamingMode(Enum):
class RunConfig(BaseModel):
"""Configs for runtime behavior of agents."""
"""Configs for runtime behavior of agents.
The configs here will be overriden by agent-specific configurations.
"""
model_config = ConfigDict(
extra='forbid',
+5
View File
@@ -60,6 +60,8 @@ class Gemini(BaseLlm):
model: str = 'gemini-2.5-flash'
speech_config: Optional[types.SpeechConfig] = None
retry_options: Optional[types.HttpRetryOptions] = None
"""Allow Gemini to retry failed responses.
@@ -269,6 +271,9 @@ class Gemini(BaseLlm):
self._live_api_version
)
if self.speech_config is not None:
llm_request.live_connect_config.speech_config = self.speech_config
llm_request.live_connect_config.system_instruction = types.Content(
role='system',
parts=[