mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-12 03:48:56 +00:00
chore(vertex-ai): remove obsolete mutation suppressions
This commit is contained in:
parent
d7d74a8b57
commit
0281ce43ef
2 changed files with 18 additions and 20 deletions
|
|
@ -147,9 +147,7 @@ _GEMINI_SPEECH_CONFIG_KEY_MAP: Final[Mapping[str, str]] = MappingProxyType(
|
|||
|
||||
|
||||
def _normalize_gemini_speech_config_item(value: Mapping[str, object]) -> dict[str, object]:
|
||||
normalized: Final[
|
||||
dict[str, object]
|
||||
] = {} # mutable-ok: iterative traversal preserves deeply nested provider payloads
|
||||
normalized: Final[dict[str, object]] = {}
|
||||
|
||||
pending: Final[ # mutable-ok: the explicit worklist must grow while avoiding recursive traversal
|
||||
list[tuple[dict[str, object] | list[object], Mapping[object, object] | list[object]]]
|
||||
|
|
@ -167,9 +165,9 @@ def _normalize_gemini_speech_config_item(value: Mapping[str, object]) -> dict[st
|
|||
|
||||
child: object
|
||||
if isinstance(item, Mapping):
|
||||
child = {} # mutable-ok: nested mappings are filled by the worklist
|
||||
child = {}
|
||||
elif isinstance(item, list):
|
||||
child = [] # mutable-ok: nested lists are filled by the worklist
|
||||
child = []
|
||||
else:
|
||||
child = item
|
||||
|
||||
|
|
@ -207,7 +205,7 @@ def normalize_gemini_speech_config(
|
|||
return {key: item for key, item in normalized.items() if key not in ("name", "voiceName", "voice")}
|
||||
if voice_name is None:
|
||||
return normalized
|
||||
return { # mutable-ok: provider request serialization requires a concrete dict
|
||||
return {
|
||||
**{key: item for key, item in normalized.items() if key not in ("name", "voiceName", "voice", "modelName")},
|
||||
"voiceConfig": {"prebuiltVoiceConfig": {"voiceName": voice_name}},
|
||||
}
|
||||
|
|
@ -1136,19 +1134,19 @@ class VertexGeminiConfig(VertexAIBaseConfig, BaseConfig):
|
|||
speech_config_without_language: Final[ # mutable-ok: provider request serialization requires a concrete dict
|
||||
dict[str, object]
|
||||
] = (
|
||||
{ # mutable-ok: provider request serialization requires a concrete dict
|
||||
"voiceConfig": { # mutable-ok: nested provider payload is serialized as a dict
|
||||
"prebuiltVoiceConfig": { # mutable-ok: nested provider payload is serialized as a dict
|
||||
{
|
||||
"voiceConfig": {
|
||||
"prebuiltVoiceConfig": {
|
||||
"voiceName": value["voice"],
|
||||
}
|
||||
}
|
||||
}
|
||||
if "voice" in value
|
||||
else {} # mutable-ok: provider request serialization requires a concrete empty dict
|
||||
else {}
|
||||
)
|
||||
|
||||
if language_code is not None:
|
||||
return { # mutable-ok: provider request serialization requires a concrete dict
|
||||
return {
|
||||
**speech_config_without_language,
|
||||
"languageCode": language_code,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -230,16 +230,16 @@ class VertexAITextToSpeechConfig(BaseTextToSpeechConfig, VertexBase):
|
|||
"multi_speaker_voice_config",
|
||||
)
|
||||
if multi_speaker_config is None:
|
||||
return [] # mutable-ok: provider request serialization requires a concrete empty list
|
||||
return []
|
||||
raw_speaker_configs: Final = multi_speaker_config.get(
|
||||
"speakerVoiceConfigs",
|
||||
multi_speaker_config.get(
|
||||
"speaker_voice_configs",
|
||||
[], # mutable-ok: missing speaker configuration uses a concrete empty-list sentinel
|
||||
[],
|
||||
),
|
||||
)
|
||||
if not isinstance(raw_speaker_configs, list):
|
||||
return [] # mutable-ok: malformed speaker configuration produces a concrete empty list
|
||||
return []
|
||||
speaker_configs: Final[ # mutable-ok: validated payloads are accumulated for serialization
|
||||
list[VertexTextToSpeechSpeakerVoiceConfig]
|
||||
] = []
|
||||
|
|
@ -269,7 +269,7 @@ class VertexAITextToSpeechConfig(BaseTextToSpeechConfig, VertexBase):
|
|||
)
|
||||
if speaker_alias is not None and speaker_id is not None:
|
||||
speaker_configs.append(
|
||||
{ # mutable-ok: provider request serialization requires a concrete dict
|
||||
{
|
||||
"speakerAlias": speaker_alias,
|
||||
"speakerId": speaker_id,
|
||||
}
|
||||
|
|
@ -305,7 +305,7 @@ class VertexAITextToSpeechConfig(BaseTextToSpeechConfig, VertexBase):
|
|||
voice: str | Mapping[str, object],
|
||||
) -> tuple[str | None, dict[str, object]]: # mutable-ok: provider request serialization requires a concrete dict
|
||||
if isinstance(voice, str):
|
||||
return voice, { # mutable-ok: provider request serialization requires a concrete dict
|
||||
return voice, {
|
||||
"languageCode": self.DEFAULT_LANGUAGE_CODE,
|
||||
"modelName": model,
|
||||
"name": voice,
|
||||
|
|
@ -320,21 +320,21 @@ class VertexAITextToSpeechConfig(BaseTextToSpeechConfig, VertexBase):
|
|||
model_name: Final = model
|
||||
speaker_configs: Final = self._extract_gemini_tts_speaker_configs(voice)
|
||||
if speaker_configs:
|
||||
return None, { # mutable-ok: provider request serialization requires a concrete dict
|
||||
return None, {
|
||||
"languageCode": language_code,
|
||||
"modelName": model_name,
|
||||
"multiSpeakerVoiceConfig": { # mutable-ok: nested provider payload is serialized as a dict
|
||||
"multiSpeakerVoiceConfig": {
|
||||
"speakerVoiceConfigs": speaker_configs,
|
||||
},
|
||||
}
|
||||
voice_name: Final = self._extract_gemini_tts_voice_name(voice)
|
||||
if voice_name is not None:
|
||||
return None, { # mutable-ok: provider request serialization requires a concrete dict
|
||||
return None, {
|
||||
"languageCode": language_code,
|
||||
"modelName": model_name,
|
||||
"name": voice_name,
|
||||
}
|
||||
return None, { # mutable-ok: provider request serialization requires a concrete dict
|
||||
return None, {
|
||||
**voice,
|
||||
"languageCode": language_code,
|
||||
"modelName": model_name,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue