Skip to content

Commit

Permalink
modify regex to allow cross-region inference in bedrock (#1120)
Browse files Browse the repository at this point in the history
* modify regex to allow cross-region inference in bedrock (only possible for claude models)

* add tests for multi-region inference with claude models
  • Loading branch information
1greentangerine authored Oct 4, 2024
1 parent cf52ce9 commit 62483b7
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class AmazonBedrockChatGenerator:
"""

SUPPORTED_MODEL_PATTERNS: ClassVar[Dict[str, Type[BedrockModelChatAdapter]]] = {
r"anthropic.claude.*": AnthropicClaudeChatAdapter,
r"(.+\.)?anthropic.claude.*": AnthropicClaudeChatAdapter,
r"meta.llama2.*": MetaLlama2ChatAdapter,
r"mistral.*": MistralChatAdapter,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class AmazonBedrockGenerator:
r"ai21.j2.*": AI21LabsJurassic2Adapter,
r"cohere.command-[^r].*": CohereCommandAdapter,
r"cohere.command-r.*": CohereCommandRAdapter,
r"anthropic.claude.*": AnthropicClaudeAdapter,
r"(.+\.)?anthropic.claude.*": AnthropicClaudeAdapter,
r"meta.llama.*": MetaLlamaAdapter,
r"mistral.*": MistralAdapter,
}
Expand Down
2 changes: 2 additions & 0 deletions integrations/amazon_bedrock/tests/test_chat_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,8 @@ def test_long_prompt_is_not_truncated_when_truncate_false(mock_boto3_session):
[
("anthropic.claude-v1", AnthropicClaudeChatAdapter),
("anthropic.claude-v2", AnthropicClaudeChatAdapter),
("eu.anthropic.claude-v1", AnthropicClaudeChatAdapter), # cross-region inference
("us.anthropic.claude-v2", AnthropicClaudeChatAdapter), # cross-region inference
("anthropic.claude-instant-v1", AnthropicClaudeChatAdapter),
("anthropic.claude-super-v5", AnthropicClaudeChatAdapter), # artificial
("meta.llama2-13b-chat-v1", MetaLlama2ChatAdapter),
Expand Down
2 changes: 2 additions & 0 deletions integrations/amazon_bedrock/tests/test_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,8 @@ def test_long_prompt_is_not_truncated_when_truncate_false(mock_boto3_session):
[
("anthropic.claude-v1", AnthropicClaudeAdapter),
("anthropic.claude-v2", AnthropicClaudeAdapter),
("eu.anthropic.claude-v1", AnthropicClaudeAdapter), # cross-region inference
("us.anthropic.claude-v2", AnthropicClaudeAdapter), # cross-region inference
("anthropic.claude-instant-v1", AnthropicClaudeAdapter),
("anthropic.claude-super-v5", AnthropicClaudeAdapter), # artificial
("cohere.command-text-v14", CohereCommandAdapter),
Expand Down

0 comments on commit 62483b7

Please sign in to comment.