Skip to content

Commit

Permalink
Use AWS_DEFAULT_REGION for bedrock if provided
Browse files Browse the repository at this point in the history
  • Loading branch information
AnirudhDagar committed Nov 19, 2024
1 parent 0906e89 commit ad890e8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,19 @@ pip install -r requirements.txt
AG-A supports using both AWS Bedrock and OpenAI as LLM model providers. You will need to set up API keys for the respective provider you choose. By default, AG-A uses AWS Bedrock for its language models.

#### AWS Bedrock Setup
AG-A integrates with AWS Bedrock by default. To use AWS Bedrock, you will need to configure your AWS credentials and region settings:
To use AWS Bedrock, you will need to configure your AWS credentials and region settings:

```bash
export AWS_DEFAULT_REGION="<your-region>"
export AWS_ACCESS_KEY_ID="<your-access-key>"
export AWS_SECRET_ACCESS_KEY="<your-secret-key>"
```

Ensure you have an active AWS account and appropriate permissions set up for using Bedrock models. You can manage your AWS credentials through the AWS Management Console. See [Bedrock supported AWS regions](https://docs.aws.amazon.com/bedrock/latest/userguide/bedrock-regions.html)
Ensure you have an active AWS account and appropriate permissions set up for using Bedrock models. You can manage your AWS credentials through the AWS Management Console. See [Bedrock supported AWS regions](https://docs.aws.amazon.com/bedrock/latest/userguide/models-regions.html).


#### OpenAI Setup
To use OpenAI, you'll need to set your OpenAI API key as an environment variable:
To use OpenAI, you will need to set your OpenAI API key as an environment variable:

```bash
export OPENAI_API_KEY="sk-..."
Expand Down
6 changes: 2 additions & 4 deletions src/autogluon/assistant/llm/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,7 @@ def get_openai_models() -> List[str]:
@staticmethod
def get_bedrock_models() -> List[str]:
try:
# TODO: Remove hardcoding AWS region
bedrock = boto3.client("bedrock", region_name="us-west-2")
bedrock = boto3.client("bedrock", region_name=os.environ.get("AWS_DEFAULT_REGION", "us-west-2"))
response = bedrock.list_foundation_models()
return [model["modelId"] for model in response["modelSummaries"]]
except Exception as e:
Expand Down Expand Up @@ -166,8 +165,7 @@ def _get_bedrock_chat_model(config: DictConfig) -> AssistantChatBedrock:
"temperature": config.temperature,
"max_tokens": config.max_tokens,
},
# TODO: Remove hardcoding AWS region
region_name="us-west-2",
region_name=os.environ.get("AWS_DEFAULT_REGION", "us-west-2"),
verbose=config.verbose,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ def __init__(
num_iterations: int = 2,
optimization_metric: str = "roc",
eval_model: str = "lightgbm",
# TODO: Remove hardcoding AWS region
region_name: str = "us-west-2",
region_name: str = os.environ.get("AWS_DEFAULT_REGION", "us-west-2"),
**kwargs,
) -> None:
# Set up credentials if using OpenAI
Expand Down

0 comments on commit ad890e8

Please sign in to comment.