mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-07 08:26:10 +00:00
allow users to set AWS_REGION_NAME
This commit is contained in:
parent
73bb1b96e9
commit
126830f08a
2 changed files with 11 additions and 4 deletions
|
|
@ -4,7 +4,7 @@ from enum import Enum
|
|||
import requests
|
||||
import time
|
||||
from typing import Callable
|
||||
from litellm.utils import ModelResponse
|
||||
from litellm.utils import ModelResponse, get_secret
|
||||
import sys
|
||||
|
||||
class SagemakerError(Exception):
|
||||
|
|
@ -21,6 +21,8 @@ os.environ['AWS_ACCESS_KEY_ID'] = ""
|
|||
os.environ['AWS_SECRET_ACCESS_KEY'] = ""
|
||||
"""
|
||||
|
||||
# set os.environ['AWS_REGION_NAME'] = <your-region_name>
|
||||
|
||||
def completion(
|
||||
model: str,
|
||||
messages: list,
|
||||
|
|
@ -35,12 +37,16 @@ def completion(
|
|||
import sys
|
||||
if 'boto3' not in sys.modules:
|
||||
import boto3
|
||||
|
||||
|
||||
region_name = (
|
||||
get_secret("AWS_REGION_NAME") or
|
||||
"us-west-2" # default to us-west-2
|
||||
)
|
||||
|
||||
client = boto3.client(
|
||||
"sagemaker-runtime",
|
||||
region_name="us-west-2"
|
||||
region_name=region_name
|
||||
)
|
||||
|
||||
|
||||
model = model
|
||||
prompt = ""
|
||||
|
|
|
|||
|
|
@ -404,6 +404,7 @@ def test_completion_sagemaker():
|
|||
print(response)
|
||||
except Exception as e:
|
||||
pytest.fail(f"Error occurred: {e}")
|
||||
test_completion_sagemaker()
|
||||
|
||||
|
||||
# def test_vertex_ai():
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue