From 8fe2c3effce798bc2791ba496d58c2796c30926e Mon Sep 17 00:00:00 2001 From: Thomas T Date: Tue, 6 Feb 2024 14:25:58 -0500 Subject: [PATCH] [Bug Fix] Add support for `AWS_REGION` override (#1237) --- docs/components/llms.mdx | 4 +++- embedchain/llm/aws_bedrock.py | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/components/llms.mdx b/docs/components/llms.mdx index 9adbc6ab..98dff333 100644 --- a/docs/components/llms.mdx +++ b/docs/components/llms.mdx @@ -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") ``` diff --git a/embedchain/llm/aws_bedrock.py b/embedchain/llm/aws_bedrock.py index e1f2521a..200a8f39 100644 --- a/embedchain/llm/aws_bedrock.py +++ b/embedchain/llm/aws_bedrock.py @@ -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",