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

fix: Allow passing boto3 config to all AWS Bedrock classes #1166

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

AnesBenmerzoug
Copy link

Related PR

Proposed Changes:

  • Updated class init signatures to allow passing additional and optional boto3_config dictionary and use it when initializing boto3 client.
  • Updated tests accordingly

How did you test it?

  • Tested locally by running hatch test

Notes for the reviewer

This is a follow up to PR !1135 that simply applies the same change to all other aws bedrock classes (AmazonBedrockDocumentEmbedder, AmazonBedrockTextEmbedder, AmazonBedrockChatGenerator).

Checklist

@AnesBenmerzoug AnesBenmerzoug requested a review from a team as a code owner November 6, 2024 10:09
@AnesBenmerzoug AnesBenmerzoug requested review from davidsbatista and removed request for a team November 6, 2024 10:09
@CLAassistant
Copy link

CLAassistant commented Nov 6, 2024

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
2 out of 3 committers have signed the CLA.

✅ AnesBenmerzoug
✅ davidsbatista
❌ HaystackBot
You have signed the CLA already but the status is still pending? Let us recheck it.

@github-actions github-actions bot added integration:amazon-bedrock type:documentation Improvements or additions to documentation labels Nov 6, 2024
@AnesBenmerzoug
Copy link
Author

@davidsbatista I could not completely sign the CLA because I accidentaly some of the commits without configuring my email address. Should I leave it like this or is it okay to update the author of those commits and force-push the change?

@@ -71,12 +72,16 @@ def test_from_dict(mock_boto3_session):
"generation_kwargs": {"temperature": 0.7},
"streaming_callback": "haystack.components.generators.utils.print_streaming_chunk",
"truncate": True,
"boto3_config": {
Copy link
Contributor

Choose a reason for hiding this comment

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

did you test that the from_dict can handle a serialized object without the newly added boto3_config? we need to be sure this change is still compatible with older versions

Copy link
Author

Choose a reason for hiding this comment

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

Done. I parametrized the tests for the boto3_cofig value.

@@ -117,6 +121,7 @@ def test_from_dict(self, mock_boto3_session):
assert embedder.progress_bar
assert embedder.meta_fields_to_embed == []
assert embedder.embedding_separator == "\n"
assert embedder.boto3_config == {"read_timeout": 1000}
Copy link
Contributor

Choose a reason for hiding this comment

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

same thing here as above

Copy link
Author

Choose a reason for hiding this comment

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

Done. I parametrized the tests for the boto3_cofig value.

@@ -76,13 +77,17 @@ def test_from_dict(self, mock_boto3_session):
"aws_profile_name": {"type": "env_var", "env_vars": ["AWS_PROFILE"], "strict": False},
"model": "cohere.embed-english-v3",
"input_type": "search_query",
"boto3_config": {
Copy link
Contributor

Choose a reason for hiding this comment

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

same thing as before

Copy link
Author

Choose a reason for hiding this comment

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

Done. I parametrized the tests for the boto3_cofig value.

@davidsbatista
Copy link
Contributor

@davidsbatista I could not completely sign the CLA because I accidentaly some of the commits without configuring my email address. Should I leave it like this or is it okay to update the author of those commits and force-push the change?

You need to sign the CLA in order for the PR to be merged, so it seems you will need to update the author of these commits.

@davidsbatista
Copy link
Contributor

davidsbatista commented Nov 12, 2024

@AnesBenmerzoug thanks for this contribution! I've left some comments regarding backward compatibility. I've also asked my colleague @vblagoje to do a second review.

@davidsbatista
Copy link
Contributor

@AnesBenmerzoug remove the parameterization of all the tests, and instead do a test such that:

  • Create and serialize a new instance without boto3config, then load/deserialize that object, and assert that new deserialized object is exactly the same as the initially created instance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants