mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-26 11:14:04 +00:00
fix(proxy_server.py): fix linting errors
This commit is contained in:
parent
284fb64f4d
commit
fbdcde1a54
2 changed files with 13 additions and 21 deletions
|
@ -295,32 +295,24 @@ def load_from_azure_key_vault(use_azure_key_vault: bool = False):
|
|||
from azure.identity import ClientSecretCredential
|
||||
|
||||
# Set your Azure Key Vault URI
|
||||
KVUri = os.getenv("AZURE_KEY_VAULT_URI")
|
||||
KVUri = os.getenv("AZURE_KEY_VAULT_URI", None)
|
||||
|
||||
# Set your Azure AD application/client ID, client secret, and tenant ID
|
||||
client_id = os.getenv("AZURE_CLIENT_ID")
|
||||
client_secret = os.getenv("AZURE_CLIENT_SECRET")
|
||||
tenant_id = os.getenv("AZURE_TENANT_ID")
|
||||
client_id = os.getenv("AZURE_CLIENT_ID", None)
|
||||
client_secret = os.getenv("AZURE_CLIENT_SECRET", None)
|
||||
tenant_id = os.getenv("AZURE_TENANT_ID", None)
|
||||
|
||||
# Initialize the ClientSecretCredential
|
||||
credential = ClientSecretCredential(client_id=client_id, client_secret=client_secret, tenant_id=tenant_id)
|
||||
if KVUri is not None and client_id is not None and client_secret is not None and tenant_id is not None:
|
||||
# Initialize the ClientSecretCredential
|
||||
credential = ClientSecretCredential(client_id=client_id, client_secret=client_secret, tenant_id=tenant_id)
|
||||
|
||||
# Create the SecretClient using the credential
|
||||
client = SecretClient(vault_url=KVUri, credential=credential)
|
||||
# Create the SecretClient using the credential
|
||||
client = SecretClient(vault_url=KVUri, credential=credential)
|
||||
|
||||
litellm.secret_manager_client = client
|
||||
# # Retrieve all secrets
|
||||
# secrets = client.get_secrets()
|
||||
|
||||
# # Load secrets into environment variables
|
||||
# for secret in secrets:
|
||||
# secret_name = secret.name
|
||||
# secret_value = client.get_secret(secret_name).value
|
||||
# os.environ[secret_name] = secret_value
|
||||
|
||||
print(f"test key - : {litellm.get_secret('test-3')}")
|
||||
litellm.secret_manager_client = client
|
||||
else:
|
||||
raise Exception(f"Missing KVUri or client_id or client_secret or tenant_id from environment")
|
||||
except Exception as e:
|
||||
print(e)
|
||||
print("Error when loading keys from Azure Key Vault. Ensure you run `pip install azure-identity azure-keyvault-secrets`")
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue