with infisical managing keys

This commit is contained in:
ishaan-jaff 2023-08-05 12:52:11 -07:00
parent 7575d7ea47
commit 2ecd132a94
5 changed files with 69 additions and 14 deletions

View file

@ -403,4 +403,21 @@ def litellm_telemetry(data):
response.raise_for_status() # Raise an exception for HTTP errors
except requests.exceptions.RequestException as e:
# Handle any errors in the request
pass
pass
######### Secret Manager ############################
# checks if user has passed in a secret manager client
# if passed in then checks the secret there
def get_secret(secret_name):
if litellm.secret_manager_client != None:
# TODO: check which secret manager is being used
# currently only supports Infisical
secret = litellm.secret_manager_client.get_secret(secret_name).secret_value
if secret != None:
# if secret manager fails default to using .env variables
os.environ[secret_name] = secret # set to env to be safe
return secret
else:
return os.environ.get(secret_name)
else:
return os.environ.get(secret_name)