[Bug Fix] Add support for AWS_REGION override (#1237)

This commit is contained in:
Thomas T
2024-02-06 14:25:58 -05:00
committed by GitHub
parent fa78c972be
commit 8fe2c3effc
2 changed files with 5 additions and 2 deletions

View File

@@ -666,7 +666,8 @@ embedder:
### Setup
- Before using the AWS Bedrock LLM, make sure you have the appropriate model access from [Bedrock Console](https://us-east-1.console.aws.amazon.com/bedrock/home?region=us-east-1#/modelaccess).
- You will also need `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` to authenticate the API with AWS. You can find these in your [AWS Console](https://us-east-1.console.aws.amazon.com/iam/home?region=us-east-1#/users).
- You will also need to authenticate the `boto3` client by using a method in the [AWS documentation](https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html#configuring-credentials)
- You can optionally export an `AWS_REGION`
### Usage
@@ -679,6 +680,7 @@ from embedchain import App
os.environ["AWS_ACCESS_KEY_ID"] = "xxx"
os.environ["AWS_SECRET_ACCESS_KEY"] = "xxx"
os.environ["AWS_REGION"] = "us-west-2"
app = App.from_config(config_path="config.yaml")
```

View File

@@ -1,3 +1,4 @@
import os
from typing import Optional
from langchain.llms import Bedrock
@@ -25,7 +26,7 @@ class AWSBedrockLlm(BaseLlm):
'Please install with `pip install --upgrade "embedchain[aws-bedrock]"`'
) from None
self.boto_client = boto3.client("bedrock-runtime", "us-west-2")
self.boto_client = boto3.client("bedrock-runtime", "us-west-2" or os.environ.get("AWS_REGION"))
kwargs = {
"model_id": config.model or "amazon.titan-text-express-v1",