mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-03 02:22:24 +00:00
fix(bedrock/converse): pop None context_management; extract helpers to fix PLR0915
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
88639d221f
commit
1b3570f974
1 changed files with 16 additions and 9 deletions
|
|
@ -936,16 +936,9 @@ class AmazonConverseConfig(BaseConfig):
|
|||
model=model, reasoning_effort=value, optional_params=optional_params
|
||||
)
|
||||
if param == "context_management" and isinstance(value, (dict, list)):
|
||||
# Forward context_management; later filter keeps compact_20260112 only.
|
||||
optional_params["context_management"] = (
|
||||
AnthropicConfig.map_openai_context_management_to_anthropic(
|
||||
cast(Union[dict, list], value)
|
||||
)
|
||||
)
|
||||
self._map_context_management_param(value, optional_params)
|
||||
if param == "requestMetadata":
|
||||
if value is not None and isinstance(value, dict):
|
||||
self._validate_request_metadata(value) # type: ignore
|
||||
optional_params["requestMetadata"] = value
|
||||
self._map_request_metadata_param(value, optional_params)
|
||||
if param == "service_tier" and isinstance(value, str):
|
||||
self._map_service_tier_param(value, optional_params)
|
||||
|
||||
|
|
@ -978,6 +971,20 @@ class AmazonConverseConfig(BaseConfig):
|
|||
|
||||
return optional_params
|
||||
|
||||
def _map_request_metadata_param(self, value: Any, optional_params: dict) -> None:
|
||||
if value is not None and isinstance(value, dict):
|
||||
self._validate_request_metadata(value) # type: ignore
|
||||
optional_params["requestMetadata"] = value
|
||||
|
||||
def _map_context_management_param(
|
||||
self, value: Union[dict, list], optional_params: dict
|
||||
) -> None:
|
||||
optional_params["context_management"] = (
|
||||
AnthropicConfig.map_openai_context_management_to_anthropic(
|
||||
cast(Union[dict, list], value)
|
||||
)
|
||||
)
|
||||
|
||||
def _map_service_tier_param(self, value: str, optional_params: dict) -> None:
|
||||
"""Map OpenAI service_tier (string) to Bedrock serviceTier (object).
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue