new mcp servers format
This commit is contained in:
@@ -610,6 +610,7 @@ async def _get_fuzzy_user_object(
|
||||
- Check if user_email is user_email in db
|
||||
- If not, create new user with user_email and sso_user_id and user_id = sso_user_id
|
||||
"""
|
||||
|
||||
response = None
|
||||
if sso_user_id is not None:
|
||||
response = await prisma_client.db.litellm_usertable.find_unique(
|
||||
@@ -952,6 +953,62 @@ async def get_team_object(
|
||||
)
|
||||
|
||||
|
||||
class ExperimentalUIJWTToken:
|
||||
@staticmethod
|
||||
def get_experimental_ui_login_jwt_auth_token(user_info: LiteLLM_UserTable) -> str:
|
||||
from datetime import UTC, datetime, timedelta
|
||||
|
||||
from litellm.proxy.common_utils.encrypt_decrypt_utils import (
|
||||
encrypt_value_helper,
|
||||
)
|
||||
|
||||
if user_info.user_role is None:
|
||||
raise Exception("User role is required for experimental UI login")
|
||||
|
||||
# Calculate expiration time (10 minutes from now)
|
||||
expiration_time = datetime.now(UTC) + timedelta(minutes=10)
|
||||
|
||||
# Format the expiration time as ISO 8601 string
|
||||
expires = expiration_time.strftime("%Y-%m-%dT%H:%M:%S.%f")[:-3] + "+00:00"
|
||||
|
||||
valid_token = UserAPIKeyAuth(
|
||||
token="ui-token",
|
||||
key_name="ui-token",
|
||||
key_alias="ui-token",
|
||||
max_budget=litellm.max_ui_session_budget,
|
||||
rpm_limit=100, # allow user to have a conversation on test key pane of UI
|
||||
expires=expires,
|
||||
user_id=user_info.user_id,
|
||||
team_id="litellm-dashboard",
|
||||
models=user_info.models,
|
||||
max_parallel_requests=None,
|
||||
user_role=LitellmUserRoles(user_info.user_role),
|
||||
)
|
||||
|
||||
return encrypt_value_helper(valid_token.model_dump_json(exclude_none=True))
|
||||
|
||||
@staticmethod
|
||||
def get_key_object_from_ui_hash_key(
|
||||
hashed_token: str,
|
||||
) -> Optional[UserAPIKeyAuth]:
|
||||
import json
|
||||
|
||||
from litellm.proxy.auth.user_api_key_auth import UserAPIKeyAuth
|
||||
from litellm.proxy.common_utils.encrypt_decrypt_utils import (
|
||||
decrypt_value_helper,
|
||||
)
|
||||
|
||||
decrypted_token = decrypt_value_helper(hashed_token, exception_type="debug")
|
||||
if decrypted_token is None:
|
||||
return None
|
||||
try:
|
||||
return UserAPIKeyAuth(**json.loads(decrypted_token))
|
||||
except Exception as e:
|
||||
raise Exception(
|
||||
f"Invalid hash key. Hash key={hashed_token}. Decrypted token={decrypted_token}. Error: {e}"
|
||||
)
|
||||
|
||||
|
||||
@log_db_metrics
|
||||
async def get_key_object(
|
||||
hashed_token: str,
|
||||
|
||||
Reference in New Issue
Block a user