mirror of
https://github.com/tiennm99/litellm.git
synced 2026-08-07 18:23:28 +00:00
fix(lint): extract service_tier mapping to fix PLR0915 in converse_transformation.py
map_openai_params had 53 statements (limit is 50). Extracted the service_tier → Bedrock serviceTier mapping into _map_service_tier_param helper, reducing the statement count to 49 with no behaviour change. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
6af3d073f0
commit
5e9a2b4e9c
@@ -932,14 +932,7 @@ class AmazonConverseConfig(BaseConfig):
|
||||
self._validate_request_metadata(value) # type: ignore
|
||||
optional_params["requestMetadata"] = value
|
||||
if param == "service_tier" and isinstance(value, str):
|
||||
# Map OpenAI service_tier (string) to Bedrock serviceTier (object)
|
||||
# OpenAI values: "auto", "default", "flex", "priority"
|
||||
# Bedrock values: "default", "flex", "priority" (no "auto")
|
||||
bedrock_tier = value
|
||||
if value == "auto":
|
||||
bedrock_tier = "default" # Bedrock doesn't support "auto"
|
||||
if bedrock_tier in ("default", "flex", "priority"):
|
||||
optional_params["serviceTier"] = {"type": bedrock_tier}
|
||||
self._map_service_tier_param(value, optional_params)
|
||||
|
||||
if param == "web_search_options" and isinstance(value, dict):
|
||||
# Note: we use `isinstance(value, dict)` instead of `value and isinstance(value, dict)`
|
||||
@@ -970,6 +963,18 @@ class AmazonConverseConfig(BaseConfig):
|
||||
|
||||
return optional_params
|
||||
|
||||
def _map_service_tier_param(self, value: str, optional_params: dict) -> None:
|
||||
"""Map OpenAI service_tier (string) to Bedrock serviceTier (object).
|
||||
|
||||
OpenAI values: "auto", "default", "flex", "priority"
|
||||
Bedrock values: "default", "flex", "priority" (no "auto")
|
||||
"""
|
||||
bedrock_tier = value
|
||||
if value == "auto":
|
||||
bedrock_tier = "default" # Bedrock doesn't support "auto"
|
||||
if bedrock_tier in ("default", "flex", "priority"):
|
||||
optional_params["serviceTier"] = {"type": bedrock_tier}
|
||||
|
||||
def _translate_response_format_param(
|
||||
self,
|
||||
value: dict,
|
||||
|
||||
Reference in New Issue
Block a user