-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adopt Secret to Amazon Bedrock (#416)
* initial import * addin Secret and fixing tests * cleaning * using staticmethod directly * removing ignore from B008 config and setting up in-line * addin Secret and fixing tests for chat component * addin Secret and fixing tests for the chat component * fixing to_dict from_dict * fixing to_dict from_dict to the chat component as well
- Loading branch information
1 parent
ec58d6f
commit d28ffa1
Showing
6 changed files
with
128 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from unittest.mock import MagicMock, patch | ||
|
||
import pytest | ||
|
||
|
||
@pytest.fixture | ||
def set_env_variables(monkeypatch): | ||
monkeypatch.setenv("AWS_ACCESS_KEY_ID", "some_fake_id") | ||
monkeypatch.setenv("AWS_SECRET_ACCESS_KEY", "some_fake_key") | ||
monkeypatch.setenv("AWS_SESSION_TOKEN", "some_fake_token") | ||
monkeypatch.setenv("AWS_DEFAULT_REGION", "fake_region") | ||
monkeypatch.setenv("AWS_PROFILE", "some_fake_profile") | ||
|
||
|
||
@pytest.fixture | ||
def mock_auto_tokenizer(): | ||
with patch("transformers.AutoTokenizer.from_pretrained", autospec=True) as mock_from_pretrained: | ||
mock_tokenizer = MagicMock() | ||
mock_from_pretrained.return_value = mock_tokenizer | ||
yield mock_tokenizer | ||
|
||
|
||
# create a fixture with mocked boto3 client and session | ||
@pytest.fixture | ||
def mock_boto3_session(): | ||
with patch("boto3.Session") as mock_client: | ||
yield mock_client | ||
|
||
|
||
@pytest.fixture | ||
def mock_prompt_handler(): | ||
with patch( | ||
"haystack_integrations.components.generators.amazon_bedrock.handlers.DefaultPromptHandler" | ||
) as mock_prompt_handler: | ||
yield mock_prompt_handler |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.