Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /BerriAI_litellm /litellm /secret_managers /google_kms.py
| """ | |
| This is a file for the Google KMS integration | |
| Relevant issue: https://github.com/BerriAI/litellm/issues/1235 | |
| Requires: | |
| * `os.environ["GOOGLE_APPLICATION_CREDENTIALS"], os.environ["GOOGLE_KMS_RESOURCE_NAME"]` | |
| * `pip install google-cloud-kms` | |
| """ | |
| import os | |
| from typing import Final | |
| import litellm | |
| from litellm.proxy._types import KeyManagementSystem | |
| def validate_environment(): | |
| if "GOOGLE_APPLICATION_CREDENTIALS" not in os.environ: | |
| raise ValueError("Missing required environment variable - GOOGLE_APPLICATION_CREDENTIALS") | |
| if "GOOGLE_KMS_RESOURCE_NAME" not in os.environ: | |
| raise ValueError("Missing required environment variable - GOOGLE_KMS_RESOURCE_NAME") | |
| def load_google_kms(use_google_kms: bool | None): | |
| if use_google_kms is None or use_google_kms is False: | |
| return | |
| try: | |
| from google.cloud import kms_v1 | |
| validate_environment() | |
| # Create the KMS client | |
| client: Final = kms_v1.KeyManagementServiceClient() | |
| litellm.secret_manager_client = client | |
| litellm._key_management_system = KeyManagementSystem.GOOGLE_KMS | |
| litellm._google_kms_resource_name = os.getenv("GOOGLE_KMS_RESOURCE_NAME") | |
| except Exception as e: | |
| raise e | |
Xet Storage Details
- Size:
- 1.23 kB
- Xet hash:
- ab3b4a2b053fd80c7a21c90d0e52e86fed21ca58e0f8e4d99eaf25573ce90830
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.