mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-27 11:43:54 +00:00
fix - don't require boto3 on the cli
This commit is contained in:
parent
a133d1f45b
commit
4a89a30f12
1 changed files with 19 additions and 17 deletions
|
@ -1,13 +1,14 @@
|
||||||
import tempfile
|
|
||||||
|
|
||||||
import boto3
|
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
from litellm._logging import verbose_proxy_logger
|
from litellm._logging import verbose_proxy_logger
|
||||||
|
|
||||||
|
|
||||||
def get_file_contents_from_s3(bucket_name, object_key):
|
def get_file_contents_from_s3(bucket_name, object_key):
|
||||||
|
try:
|
||||||
# v0 rely on boto3 for authentication - allowing boto3 to handle IAM credentials etc
|
# v0 rely on boto3 for authentication - allowing boto3 to handle IAM credentials etc
|
||||||
|
import tempfile
|
||||||
|
|
||||||
|
import boto3
|
||||||
from botocore.config import Config
|
from botocore.config import Config
|
||||||
from botocore.credentials import Credentials
|
from botocore.credentials import Credentials
|
||||||
|
|
||||||
|
@ -20,8 +21,6 @@ def get_file_contents_from_s3(bucket_name, object_key):
|
||||||
aws_secret_access_key=credentials.secret_key,
|
aws_secret_access_key=credentials.secret_key,
|
||||||
aws_session_token=credentials.token, # Optional, if using temporary credentials
|
aws_session_token=credentials.token, # Optional, if using temporary credentials
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
|
||||||
verbose_proxy_logger.debug(
|
verbose_proxy_logger.debug(
|
||||||
f"Retrieving {object_key} from S3 bucket: {bucket_name}"
|
f"Retrieving {object_key} from S3 bucket: {bucket_name}"
|
||||||
)
|
)
|
||||||
|
@ -43,6 +42,9 @@ def get_file_contents_from_s3(bucket_name, object_key):
|
||||||
config = yaml.safe_load(yaml_file)
|
config = yaml.safe_load(yaml_file)
|
||||||
|
|
||||||
return config
|
return config
|
||||||
|
except ImportError:
|
||||||
|
# this is most likely if a user is not using the litellm docker container
|
||||||
|
pass
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
verbose_proxy_logger.error(f"Error retrieving file contents: {str(e)}")
|
verbose_proxy_logger.error(f"Error retrieving file contents: {str(e)}")
|
||||||
return None
|
return None
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue