forked from phoenix/litellm-mirror
use helper to get_config_file_contents_from_gcs
This commit is contained in:
parent
8d6a0bdc81
commit
051ac50fca
1 changed files with 20 additions and 1 deletions
|
@ -42,7 +42,7 @@ def get_file_contents_from_s3(bucket_name, object_key):
|
|||
config = yaml.safe_load(yaml_file)
|
||||
|
||||
return config
|
||||
except ImportError:
|
||||
except ImportError as e:
|
||||
# this is most likely if a user is not using the litellm docker container
|
||||
verbose_proxy_logger.error(f"ImportError: {str(e)}")
|
||||
pass
|
||||
|
@ -51,6 +51,25 @@ def get_file_contents_from_s3(bucket_name, object_key):
|
|||
return None
|
||||
|
||||
|
||||
async def get_config_file_contents_from_gcs(bucket_name, object_key):
|
||||
try:
|
||||
from litellm.integrations.gcs_bucket import GCSBucketLogger
|
||||
|
||||
gcs_bucket = GCSBucketLogger(
|
||||
bucket_name=bucket_name,
|
||||
)
|
||||
file_contents = await gcs_bucket.download_gcs_object(object_key)
|
||||
# file_contentis is a bytes object, so we need to convert it to yaml
|
||||
file_contents = file_contents.decode("utf-8")
|
||||
# convert to yaml
|
||||
config = yaml.safe_load(file_contents)
|
||||
return config
|
||||
|
||||
except:
|
||||
verbose_proxy_logger.error(f"Error retrieving file contents: {str(e)}")
|
||||
return None
|
||||
|
||||
|
||||
# # Example usage
|
||||
# bucket_name = 'litellm-proxy'
|
||||
# object_key = 'litellm_proxy_config.yaml'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue