mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-03 02:22:24 +00:00
refactor(bedrock): match :bedrock: ARN service field in is_bedrock_arn_model
Tighten the ARN detection so it pins "bedrock" to the colon-delimited service field of the ARN rather than matching the substring anywhere. This avoids a false positive for another service's ARN whose resource name merely contains "bedrock" (e.g. arn:aws:sagemaker:...:endpoint/my-bedrock-transcriber).
This commit is contained in:
parent
06c99bb5be
commit
6698adc1e4
2 changed files with 5 additions and 2 deletions
|
|
@ -767,9 +767,11 @@ class LiteLLMAnthropicMessagesAdapter:
|
|||
|
||||
These ARNs contain neither "anthropic" nor "claude", so is_anthropic_claude_model
|
||||
cannot identify them even though, on the /v1/messages endpoint, they point at Claude.
|
||||
Match ":bedrock:" in the ARN service field so another service's ARN that merely names
|
||||
bedrock in a resource (arn:aws:sagemaker:.../my-bedrock-endpoint) is not matched.
|
||||
"""
|
||||
model_lower = model.lower()
|
||||
return "arn:" in model_lower and "bedrock" in model_lower
|
||||
return "arn:" in model_lower and ":bedrock:" in model_lower
|
||||
|
||||
@staticmethod
|
||||
def translate_thinking_for_model(
|
||||
|
|
|
|||
|
|
@ -1427,11 +1427,12 @@ def test_cache_control_not_preserved_for_non_claude_model():
|
|||
),
|
||||
("bedrock/amazon.titan-text-express-v1", False),
|
||||
("arn:aws:sagemaker:us-east-1:123:endpoint/my-endpoint", False),
|
||||
("arn:aws:sagemaker:us-east-1:123:endpoint/my-bedrock-transcriber", False),
|
||||
(CACHE_CONTROL_NON_ANTHROPIC_MODEL, False),
|
||||
],
|
||||
)
|
||||
def test_is_bedrock_arn_model(model, expected):
|
||||
"""is_bedrock_arn_model requires both an ARN and the bedrock service in the string."""
|
||||
"""is_bedrock_arn_model requires an ARN with bedrock in the service field, not just anywhere."""
|
||||
assert LiteLLMAnthropicMessagesAdapter.is_bedrock_arn_model(model) is expected
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue