Files
litellm/test_pydantic_fields.py
Krish Dholakia 6bb1d77f45 Org level tpm/rpm limits + Team tpm/rpm validation when assigned to org (#15549)
* fix(support-model-specific-tpm/rpm-limits): Allows setting rate limits by tpm/rpm for models by team

* fix(key_management_endpoints.py): enforce guaranteed throughput with key-level model tpm/rpm limits, when team-level tpm/rpm limits are set

* test: add unit testing

* feat(schema.prisma): add metadata to litellm budget table

* feat(proxy/utils.py): add org limits to user api key auth

allows org level tpm/rpm limiting to work

* feat: add org level tpm/rpm limits + inherit org id in key from team

enables org level tpm/rpm limits

* feat: validated working org tpm/rpm limits

* feat: support updating org level, model specific tpm/rpm limits

* fix: working key validation for org level tpm/rpm limits

* fix: working validation for orgs when giving tpm/rpm to teams

* fix(key_management_endpoints.py): fix tpm/rpm limits on orgs

* fix(key_management_endpoints.py): support limits

* refactor: remove duplicate var

* fix: refactor to avoid ruff errors

* fix: fix typign

* fix: fix linting error

* fix: fix testing

* fix(key_management_endpoints.py): document params
2025-10-25 13:40:29 -07:00

43 lines
1.5 KiB
Python

from litellm.proxy._types import GenerateKeyRequest
# Test 1: Check if fields exist in model
print("=== Test 1: Check model_fields ===")
print(
f"rpm_limit_type in model_fields: {'rpm_limit_type' in GenerateKeyRequest.model_fields}"
)
print(
f"tpm_limit_type in model_fields: {'tpm_limit_type' in GenerateKeyRequest.model_fields}"
)
# Test 2: Create instance with empty dict (simulating FastAPI parsing minimal request)
print("\n=== Test 2: Create instance with minimal data ===")
instance = GenerateKeyRequest()
print(f"Instance created: {instance}")
print(f"Instance dict: {instance.model_dump()}")
# Test 3: Try to access the fields
print("\n=== Test 3: Try direct attribute access ===")
try:
print(f"instance.rpm_limit_type = {instance.rpm_limit_type}")
print(f"instance.tpm_limit_type = {instance.tpm_limit_type}")
except AttributeError as e:
print(f"AttributeError: {e}")
# Test 4: Try getattr
print("\n=== Test 4: Try getattr ===")
print(
f"getattr(instance, 'rpm_limit_type', None) = {getattr(instance, 'rpm_limit_type', None)}"
)
print(
f"getattr(instance, 'tpm_limit_type', None) = {getattr(instance, 'tpm_limit_type', None)}"
)
# Test 5: Check what fields are actually set
print("\n=== Test 5: Check model_fields_set ===")
print(f"model_fields_set: {instance.model_fields_set}")
# Test 6: Check instance __dict__
print("\n=== Test 6: Check instance __dict__ ===")
print(f"'rpm_limit_type' in __dict__: {'rpm_limit_type' in instance.__dict__}")
print(f"'tpm_limit_type' in __dict__: {'tpm_limit_type' in instance.__dict__}")