mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-21 00:21:49 +00:00
refactor(bedrock): inline maxTokens clamp and cover inference-profile ARNs in tests
This commit is contained in:
parent
665327249d
commit
12120fe59b
2 changed files with 5 additions and 8 deletions
|
|
@ -382,12 +382,6 @@ class AmazonConverseConfig(BaseConfig):
|
|||
def _requires_min_max_tokens(model: str) -> bool:
|
||||
return re.search(r"openai\.gpt-\d|xai\.grok-", model) is not None
|
||||
|
||||
@staticmethod
|
||||
def _enforce_min_max_tokens(max_tokens: object) -> object:
|
||||
if isinstance(max_tokens, int) and max_tokens < BEDROCK_OPENAI_COMPAT_MIN_MAX_TOKENS:
|
||||
return BEDROCK_OPENAI_COMPAT_MIN_MAX_TOKENS
|
||||
return max_tokens
|
||||
|
||||
def _is_nova_2_model(self, model: str) -> bool:
|
||||
"""
|
||||
Check if the model is a Nova 2 model that supports reasoningConfig.
|
||||
|
|
@ -1011,8 +1005,8 @@ class AmazonConverseConfig(BaseConfig):
|
|||
)
|
||||
if param == "max_tokens" or param == "max_completion_tokens":
|
||||
optional_params["maxTokens"] = (
|
||||
self._enforce_min_max_tokens(value)
|
||||
if self._requires_min_max_tokens(model) and isinstance(value, int)
|
||||
max(value, BEDROCK_OPENAI_COMPAT_MIN_MAX_TOKENS)
|
||||
if isinstance(value, int) and self._requires_min_max_tokens(model)
|
||||
else value
|
||||
)
|
||||
if param == "stream":
|
||||
|
|
|
|||
|
|
@ -467,6 +467,9 @@ def test_reasoning_with_forced_tool_choice_switches_to_auto():
|
|||
("global.xai.grok-4.6", "max_completion_tokens", 1, 16),
|
||||
("us.xai.grok-4.6", "max_tokens", 32, 32),
|
||||
("anthropic.claude-sonnet-4-5-20250929-v1:0", "max_tokens", 1, 1),
|
||||
("arn:aws:bedrock:us-east-1:123456789012:inference-profile/us.openai.gpt-6-astra", "max_tokens", 1, 16),
|
||||
("arn:aws:bedrock:us-east-1:123456789012:inference-profile/global.xai.grok-4.6", "max_tokens", 1, 16),
|
||||
("arn:aws:bedrock:us-east-1:123456789012:application-inference-profile/abc123xyz", "max_tokens", 1, 1),
|
||||
],
|
||||
)
|
||||
def test_map_openai_params_enforces_minimum_max_tokens_for_openai_compat_models(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue