mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-07 02:59:05 +00:00
fix(bedrock): restore output_config forwarding and black formatting
Use model-map lookup with _model_supports_effort_param fallback so Bedrock Invoke keeps output_config for Claude 4.6/4.7 when pricing flags are missing. Revert custom_llm_provider=bedrock for supports_output_config checks, fix allowlist test model, and apply black to xai/vertex files failing lint CI. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
64c5e8c6c1
commit
3936f84b2e
6 changed files with 19 additions and 10 deletions
|
|
@ -170,8 +170,13 @@ class AmazonAnthropicClaudeConfig(AmazonInvokeConfig, AnthropicConfig):
|
|||
anthropic_request.pop("model", None)
|
||||
anthropic_request.pop("stream", None)
|
||||
anthropic_request.pop("output_format", None)
|
||||
if not _supports_factory(
|
||||
model=model, custom_llm_provider="bedrock", key="supports_output_config"
|
||||
if not (
|
||||
_supports_factory(
|
||||
model=model,
|
||||
custom_llm_provider=None,
|
||||
key="supports_output_config",
|
||||
)
|
||||
or AnthropicConfig._model_supports_effort_param(model)
|
||||
):
|
||||
anthropic_request.pop("output_config", None)
|
||||
if "anthropic_version" not in anthropic_request:
|
||||
|
|
|
|||
|
|
@ -561,8 +561,13 @@ class AmazonAnthropicClaudeMessagesConfig(
|
|||
# 5b. Bedrock Invoke supports output_config (effort) for Claude 4.6+ models,
|
||||
# but older models do not — strip it to avoid request rejection.
|
||||
# Ref: https://github.com/BerriAI/litellm/issues/22797
|
||||
if not _supports_factory(
|
||||
model=model, custom_llm_provider="bedrock", key="supports_output_config"
|
||||
if not (
|
||||
_supports_factory(
|
||||
model=model,
|
||||
custom_llm_provider=None,
|
||||
key="supports_output_config",
|
||||
)
|
||||
or AnthropicConfig._model_supports_effort_param(model)
|
||||
):
|
||||
anthropic_messages_request.pop("output_config", None)
|
||||
|
||||
|
|
|
|||
|
|
@ -966,6 +966,7 @@ class VertexBase:
|
|||
credential_project_id,
|
||||
)
|
||||
)
|
||||
|
||||
# Clean up the entry automatically when the task finishes so
|
||||
# that long-running proxies with many credential keys do not
|
||||
# accumulate stale references.
|
||||
|
|
|
|||
|
|
@ -226,9 +226,7 @@ class XAIChatConfig(OpenAIGPTConfig):
|
|||
verbose_logger.debug(f"Error extracting X.AI web search usage: {e}")
|
||||
|
||||
self._fold_reasoning_tokens_into_completion(response)
|
||||
self._normalize_openai_compatible_usage_totals(
|
||||
getattr(response, "usage", None)
|
||||
)
|
||||
self._normalize_openai_compatible_usage_totals(getattr(response, "usage", None))
|
||||
return response
|
||||
|
||||
@staticmethod
|
||||
|
|
|
|||
|
|
@ -449,7 +449,7 @@ def test_bedrock_chat_invoke_checks_output_config_support_with_bedrock_provider(
|
|||
|
||||
mock_supports_factory.assert_called_once_with(
|
||||
model="us.anthropic.claude-opus-4-7",
|
||||
custom_llm_provider="bedrock",
|
||||
custom_llm_provider=None,
|
||||
key="supports_output_config",
|
||||
)
|
||||
assert result["output_config"] == {"effort": "high"}
|
||||
|
|
|
|||
|
|
@ -694,7 +694,7 @@ def test_bedrock_messages_checks_output_config_support_with_bedrock_provider():
|
|||
|
||||
mock_supports_factory.assert_called_with(
|
||||
model="us.anthropic.claude-opus-4-7",
|
||||
custom_llm_provider="bedrock",
|
||||
custom_llm_provider=None,
|
||||
key="supports_output_config",
|
||||
)
|
||||
assert result["output_config"] == {"effort": "high"}
|
||||
|
|
@ -1148,7 +1148,7 @@ def test_bedrock_messages_allowlist_filters_anthropic_only_fields():
|
|||
}
|
||||
|
||||
result = cfg.transform_anthropic_messages_request(
|
||||
model="anthropic.claude-3-haiku-20240307-v1:0",
|
||||
model="anthropic.claude-opus-4-7",
|
||||
messages=messages,
|
||||
anthropic_messages_optional_request_params=optional_params,
|
||||
litellm_params=GenericLiteLLMParams(),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue