mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-05 02:41:56 +00:00
fix(gemini realtime): deep-merge nested config in follow-up session update
Previously, the follow-up setup performed a shallow merge between the original setup and new overrides. If a session.update touched any field inside generationConfig (e.g. modalities), the entire generationConfig would be replaced, silently dropping unrelated sub-keys like temperature or maxOutputTokens. Apply the same deep-merge to realtimeInputConfig so partial automatic-activity-detection updates don't drop other realtime input config fields either. Co-authored-by: Yassin Kortam <yassin@berri.ai>
This commit is contained in:
parent
76a82447e8
commit
a0043494a0
1 changed files with 21 additions and 0 deletions
|
|
@ -349,6 +349,27 @@ class GeminiRealtimeConfig(BaseRealtimeConfig):
|
|||
**new_overrides,
|
||||
"model": f"models/{model}",
|
||||
}
|
||||
# Deep-merge nested config dicts so that a partial session.update
|
||||
# (e.g. only ``modalities``) does not silently drop unrelated
|
||||
# sub-keys (e.g. ``temperature``) from the original setup.
|
||||
original_generation_config = original_setup.get("generationConfig")
|
||||
new_generation_config = new_overrides.get("generationConfig")
|
||||
if isinstance(original_generation_config, dict) and isinstance(
|
||||
new_generation_config, dict
|
||||
):
|
||||
follow_up_setup["generationConfig"] = {
|
||||
**original_generation_config,
|
||||
**new_generation_config,
|
||||
}
|
||||
original_realtime_input_config = original_setup.get("realtimeInputConfig")
|
||||
new_realtime_input_config = new_overrides.get("realtimeInputConfig")
|
||||
if isinstance(original_realtime_input_config, dict) and isinstance(
|
||||
new_realtime_input_config, dict
|
||||
):
|
||||
follow_up_setup["realtimeInputConfig"] = {
|
||||
**original_realtime_input_config,
|
||||
**new_realtime_input_config,
|
||||
}
|
||||
verbose_logger.debug(
|
||||
"Gemini Realtime: Forwarding session.update as follow-up setup"
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue