mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-02 02:11:58 +00:00
fix(bedrock): keep converse extension params on the converse route
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
parent
f4d84f8f5d
commit
e653217228
2 changed files with 24 additions and 2 deletions
|
|
@ -890,7 +890,16 @@ def bedrock_runtime_chat_completions_enforces_response_format(model: str) -> boo
|
|||
|
||||
|
||||
BEDROCK_CONVERSE_ONLY_REQUEST_KEYS: Final = frozenset(
|
||||
("guardrailConfig", "performanceConfig", "serviceTier", "requestMetadata", "outputConfig", "thinking")
|
||||
(
|
||||
"guardrailConfig",
|
||||
"performanceConfig",
|
||||
"serviceTier",
|
||||
"requestMetadata",
|
||||
"outputConfig",
|
||||
"thinking",
|
||||
"additionalModelRequestFields",
|
||||
"top_k",
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -910,7 +919,8 @@ def bedrock_request_needs_converse(model: str, request_params: Mapping[str, obje
|
|||
"""Whether a request on a runtime-Chat-Completions model must still be served by Converse.
|
||||
|
||||
Converse-shaped body keys (``BEDROCK_CONVERSE_ONLY_REQUEST_KEYS``, the Anthropic-style ``thinking``
|
||||
block included, which only Converse forwards as ``additionalModelRequestFields``) have no field on
|
||||
block and the ``additionalModelRequestFields`` / ``top_k`` extension params included, which only Converse
|
||||
forwards as ``additionalModelRequestFields`` and ``inferenceConfig``) have no field on
|
||||
AWS's native OpenAI surface, operator-owned request metadata is only written onto the Converse body,
|
||||
function tools (``tools`` or legacy ``functions``) on a model without
|
||||
``supports_bedrock_runtime_chat_completions_tools_with_reasoning`` are rejected there unless
|
||||
|
|
|
|||
|
|
@ -258,6 +258,18 @@ def test_guardrail_config_falls_back_to_converse(local_cost_map, model):
|
|||
assert BedrockModelInfo.get_bedrock_route(model, {"guardrailConfig": None}) == "chat_completions"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("model", ["openai.gpt-oss-20b-1:0", "us.xai.grok-4.6"])
|
||||
@pytest.mark.parametrize(
|
||||
"request_params",
|
||||
[{"additionalModelRequestFields": {"reasoning_effort": "high"}}, {"top_k": 40}],
|
||||
ids=["additionalModelRequestFields", "top_k"],
|
||||
)
|
||||
def test_converse_extension_params_fall_back_to_converse(local_cost_map, model, request_params):
|
||||
assert bedrock_request_needs_converse(model, request_params) is True
|
||||
assert BedrockModelInfo.get_bedrock_route(model, request_params) == "converse"
|
||||
assert BedrockModelInfo.get_bedrock_route(model, {key: None for key in request_params}) == "chat_completions"
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"request_params, expected_route",
|
||||
[
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue