Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support model_arn in AmazonBedrockGenerator #1244

Merged
merged 5 commits into from
Dec 11, 2024

Conversation

tstadel
Copy link
Member

@tstadel tstadel commented Dec 11, 2024

Related Issues

  • fixes support for model_arn as model_id

Proposed Changes:

  • model_family param which explicitly chooses model adapter if it can't be infered from model name

How did you test it?

  • added tests

Notes for the reviewer

Checklist

@tstadel tstadel requested a review from a team as a code owner December 11, 2024 10:57
@tstadel tstadel requested review from julian-risch and removed request for a team December 11, 2024 10:57
@github-actions github-actions bot added integration:amazon-bedrock type:documentation Improvements or additions to documentation labels Dec 11, 2024
Copy link
Member

@julian-risch julian-risch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks quite good to me already. Just add model_family param to the docstring of the get_model_adapter method and I'd suggest to set model_family to None by default.

@@ -250,17 +271,28 @@ def run(
return {"replies": replies}

@classmethod
def get_model_adapter(cls, model: str) -> Optional[Type[BedrockModelAdapter]]:
def get_model_adapter(cls, model: str, model_family: Optional[str]) -> Type[BedrockModelAdapter]:
"""
Gets the model adapter for the given model.

:param model: The model name.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add a docstring for model_family here

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not set model_family to None by default?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

],
)
def test_get_model_adapter(model: str, expected_model_adapter: Optional[Type[BedrockModelAdapter]]):
"""
Test that the correct model adapter is returned for a given model
"""
model_adapter = AmazonBedrockGenerator.get_model_adapter(model=model)
model_adapter = AmazonBedrockGenerator.get_model_adapter(model=model, model_family=None)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If model_family is set to None by default, we don't need to pass it here explicitly.

Test that an error is raised when auto-detection of model_family fails
"""
with pytest.raises(AmazonBedrockConfigurationError):
AmazonBedrockGenerator.get_model_adapter(model="arn:123435423", model_family=None)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can leave out model_family=None if we set it to None by default

@tstadel tstadel requested a review from julian-risch December 11, 2024 12:32
Copy link
Member

@julian-risch julian-risch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 👍

@julian-risch julian-risch merged commit 27a91ff into main Dec 11, 2024
10 checks passed
@julian-risch julian-risch deleted the feat/support_model_arn branch December 11, 2024 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integration:amazon-bedrock type:documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants