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

[Bug]: Bedrock client uses incorrect environment variables for authentication #4657

Merged
merged 1 commit into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions autogen/oai/anthropic.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,13 @@ def __init__(self, **kwargs: Any):
self._api_key = os.getenv("ANTHROPIC_API_KEY")

if not self._aws_access_key:
self._aws_access_key = os.getenv("AWS_ACCESS_KEY")
self._aws_access_key = os.getenv("AWS_ACCESS_KEY_ID")

if not self._aws_secret_key:
self._aws_secret_key = os.getenv("AWS_SECRET_KEY")
self._aws_secret_key = os.getenv("AWS_SECRET_ACCESS_KEY")

if not self._aws_region:
self._aws_region = os.getenv("AWS_REGION")
self._aws_region = os.getenv("AWS_DEFAULT_REGION")

if self._api_key is None and (
self._aws_access_key is None or self._aws_secret_key is None or self._aws_region is None
Expand Down
6 changes: 3 additions & 3 deletions autogen/oai/bedrock.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,16 @@ def __init__(self, **kwargs: Any):
self._aws_profile_name = kwargs.get("aws_profile_name", None)

if not self._aws_access_key:
self._aws_access_key = os.getenv("AWS_ACCESS_KEY")
self._aws_access_key = os.getenv("AWS_ACCESS_KEY_ID")

if not self._aws_secret_key:
self._aws_secret_key = os.getenv("AWS_SECRET_KEY")
self._aws_secret_key = os.getenv("AWS_SECRET_ACCESS_KEY")

if not self._aws_session_token:
self._aws_session_token = os.getenv("AWS_SESSION_TOKEN")

if not self._aws_region:
self._aws_region = os.getenv("AWS_REGION")
self._aws_region = os.getenv("AWS_DEFAULT_REGION")

if self._aws_region is None:
raise ValueError("Region is required to use the Amazon Bedrock API.")
Expand Down
6 changes: 3 additions & 3 deletions test/oai/test_anthropic.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ def anthropic_client():
@pytest.mark.skipif(skip, reason=reason)
def test_initialization_missing_api_key():
os.environ.pop("ANTHROPIC_API_KEY", None)
os.environ.pop("AWS_ACCESS_KEY", None)
os.environ.pop("AWS_SECRET_KEY", None)
os.environ.pop("AWS_ACCESS_KEY_ID", None)
os.environ.pop("AWS_SECRET_ACCESS_KEY", None)
os.environ.pop("AWS_SESSION_TOKEN", None)
os.environ.pop("AWS_REGION", None)
os.environ.pop("AWS_DEFAULT_REGION", None)
with pytest.raises(ValueError, match="API key or AWS credentials are required to use the Anthropic API."):
AnthropicClient()

Expand Down
Loading