feat(proxy_server.py): enable custom branding + routes on openapi docs

Allows user to add their branding + show only openai routes on docs
This commit is contained in:
Krrish Dholakia 2024-05-17 15:21:29 -07:00
parent 943c8a4dad
commit 9ab2389b7e
4 changed files with 89 additions and 11 deletions

View file

@ -0,0 +1,42 @@
# What is this?
## If litellm license in env, checks if it's valid
import os
from litellm.llms.custom_httpx.http_handler import HTTPHandler
class LicenseCheck:
"""
- Check if license in env
- Returns if license is valid
"""
base_url = "https://license.litellm.ai"
def __init__(self) -> None:
self.license_str = os.getenv("LITELLM_LICENSE", None)
self.http_handler = HTTPHandler()
def _verify(self, license_str: str) -> bool:
url = "{}/verify_license/{}".format(self.base_url, license_str)
try: # don't impact user, if call fails
response = self.http_handler.get(url=url)
response.raise_for_status()
response_json = response.json()
premium = response_json["valid"]
assert isinstance(premium, bool)
return premium
except Exception as e:
return False
def is_premium(self) -> bool:
if self.license_str is None:
return False
elif self._verify(license_str=self.license_str):
return True
return False