forked from phoenix/litellm-mirror
update get secret logic
This commit is contained in:
parent
841ac5ab20
commit
9497175a97
2 changed files with 8 additions and 9 deletions
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
try:
|
||||||
secret = litellm.secret_manager_client.get_secret(
|
secret = litellm.secret_manager_client.get_secret(
|
||||||
secret_name).secret_value
|
secret_name).secret_value
|
||||||
if secret != None:
|
except:
|
||||||
return secret # if secret found in secret manager return it
|
secret = None
|
||||||
else:
|
return secret
|
||||||
raise ValueError(
|
|
||||||
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:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue