mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-08 22:21:35 +00:00
[Chore] Check team counts on license when creating new team (#11943)
* is_team_count_over_limit * add is_team_count_over_limit
This commit is contained in:
parent
c4c8d9a250
commit
57121b4fcc
2 changed files with 22 additions and 0 deletions
|
|
@ -140,6 +140,18 @@ class LicenseCheck:
|
|||
):
|
||||
return False
|
||||
return total_users > self.airgapped_license_data["max_users"]
|
||||
|
||||
def is_team_count_over_limit(self, team_count: int) -> bool:
|
||||
"""
|
||||
Check if the license is over the limit
|
||||
"""
|
||||
if self.airgapped_license_data is None:
|
||||
return False
|
||||
if "max_teams" not in self.airgapped_license_data or not isinstance(
|
||||
self.airgapped_license_data["max_teams"], int
|
||||
):
|
||||
return False
|
||||
return team_count > self.airgapped_license_data["max_teams"]
|
||||
|
||||
def verify_license_without_api_request(self, public_key, license_key):
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -295,6 +295,7 @@ async def new_team( # noqa: PLR0915
|
|||
"""
|
||||
try:
|
||||
from litellm.proxy.proxy_server import (
|
||||
_license_check,
|
||||
create_audit_log_for_update,
|
||||
litellm_proxy_admin_name,
|
||||
prisma_client,
|
||||
|
|
@ -302,6 +303,15 @@ async def new_team( # noqa: PLR0915
|
|||
|
||||
if prisma_client is None:
|
||||
raise HTTPException(status_code=500, detail={"error": "No db connected"})
|
||||
|
||||
|
||||
# Check if license is over limit
|
||||
total_teams = await prisma_client.db.litellm_teamtable.count()
|
||||
if total_teams and _license_check.is_team_count_over_limit(team_count=total_teams):
|
||||
raise HTTPException(
|
||||
status_code=403,
|
||||
detail="License is over limit. Please contact support@berri.ai to upgrade your license.",
|
||||
)
|
||||
|
||||
if data.team_id is None:
|
||||
data.team_id = str(uuid.uuid4())
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue