From 1add0d604ec96e0110132c8a699fba6bcaab524d Mon Sep 17 00:00:00 2001 From: canada4663 <3118399+canada4663@users.noreply.github.com> Date: Sat, 28 Oct 2023 21:33:34 -0700 Subject: [PATCH] add in ability to read AWS boto3 default AWS Region name if litellm .env config AWS_REGION_NAME not available --- litellm/llms/bedrock.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/litellm/llms/bedrock.py b/litellm/llms/bedrock.py index 47ca4ad391..62760a48c8 100644 --- a/litellm/llms/bedrock.py +++ b/litellm/llms/bedrock.py @@ -1,4 +1,5 @@ import json, copy, types +import os from enum import Enum import time from typing import Callable, Optional @@ -190,11 +191,14 @@ def init_bedrock_client( ) else: # aws_access_key_id is None, assume user is trying to auth using env variables - # boto3 automaticaly reads env variables + # boto3 automatically reads env variables # we need to read region name from env - # I assume majority of users use .env for auth + # I assume majority of users use .env for auth region_name = get_secret("AWS_REGION_NAME") # reads env for AWS_REGION_NAME, defaults to None + # if litellm config `AWS_REGION_NAME` is not set, attempt to read AWS default env variable name `AWS_REGION` + if not region_name: + region_name = get_secret("AWS_REGION") client = boto3.client( service_name="bedrock-runtime", region_name=region_name,