Skip to content

armgit / mem0

Public Imported from GitHub
0

The Memory Layer for AI Agents - Drop-in memory infrastructure for AI agents and apps. Context that persists. Built for production.

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

Thomas T8fe2c3effce7
diff --git a/docs/components/llms.mdx b/docs/components/llms.mdx
index 9adbc6abe..98dff3331 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 e1f2521ab..200a8f390 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",