mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-09 22:31:41 +00:00
fix(gemini realtime): preserve original setup config on follow-up session.update
Gemini Live treats a second BidiGenerateContentSetup as a full session replacement, not a partial merge. The guardrail-driven turn_detection-only session.update was emitting a setup containing only model + realtimeInputConfig, which would silently drop tools, generationConfig, inputAudioTranscription, and systemInstruction from the original setup. Carry forward the cached original setup and only override realtimeInputConfig. Co-authored-by: Yassin Kortam <yassin@berri.ai>
This commit is contained in:
parent
00cde9da7c
commit
50ef9c8c21
1 changed files with 14 additions and 0 deletions
|
|
@ -346,7 +346,21 @@ class GeminiRealtimeConfig(BaseRealtimeConfig):
|
|||
cast(OpenAIRealtimeTurnDetection, turn_detection)
|
||||
)
|
||||
if len(transformed_audio_activity_config) > 0:
|
||||
# Gemini Live treats a subsequent BidiGenerateContentSetup as a
|
||||
# full session replacement rather than a partial merge. Carry
|
||||
# forward the original setup (tools, generationConfig,
|
||||
# inputAudioTranscription, systemInstruction, ...) and only
|
||||
# override realtimeInputConfig so the guardrail-driven VAD
|
||||
# change doesn't silently drop tools or other config.
|
||||
try:
|
||||
original_setup = cast(
|
||||
BidiGenerateContentSetup,
|
||||
json.loads(session_configuration_request).get("setup", {}),
|
||||
)
|
||||
except (json.JSONDecodeError, AttributeError):
|
||||
original_setup = {}
|
||||
follow_up_setup: BidiGenerateContentSetup = {
|
||||
**original_setup,
|
||||
"model": f"models/{model}",
|
||||
"realtimeInputConfig": BidiGenerateContentRealtimeInputConfig(
|
||||
automaticActivityDetection=transformed_audio_activity_config
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue