update get secret logic

This commit is contained in:
Krrish Dholakia 2023-08-28 07:21:02 -07:00
parent 841ac5ab20
commit 9497175a97
2 changed files with 8 additions and 9 deletions

View file

@ -211,9 +211,9 @@ def completion(
openai.api_type = "openai" openai.api_type = "openai"
# note: if a user sets a custom base - we should ensure this works # note: if a user sets a custom base - we should ensure this works
api_base = ( api_base = (
custom_api_base or litellm.api_base or get_secret("OPENAI_API_BASE") custom_api_base or litellm.api_base or get_secret("OPENAI_API_BASE") or "https://api.openai.com/v1"
) )
openai.api_base = api_base or "https://api.openai.com/v1" openai.api_base = api_base
openai.api_version = None openai.api_version = None
if litellm.organization: if litellm.organization:
openai.organization = litellm.organization openai.organization = litellm.organization

View file

@ -1444,13 +1444,12 @@ def get_secret(secret_name):
if litellm.secret_manager_client != None: if litellm.secret_manager_client != None:
# TODO: check which secret manager is being used # TODO: check which secret manager is being used
# currently only supports Infisical # currently only supports Infisical
secret = litellm.secret_manager_client.get_secret( try:
secret_name).secret_value secret = litellm.secret_manager_client.get_secret(
if secret != None: secret_name).secret_value
return secret # if secret found in secret manager return it except:
else: secret = None
raise ValueError( return secret
f"Secret '{secret_name}' not found in secret manager")
elif litellm.api_key != None: # if users use litellm default key elif litellm.api_key != None: # if users use litellm default key
return litellm.api_key return litellm.api_key
else: else: