From 96122a4f8878b1e59410bd92862f74f0021ac472 Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Thu, 18 Jan 2024 09:32:14 -0800 Subject: [PATCH] fix(proxy/utils.py): fix isoformat to string logic --- litellm/proxy/proxy_server.py | 7 ++++--- litellm/proxy/utils.py | 16 +++++++++------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.py index 27576bf51a58..d3667892bb1c 100644 --- a/litellm/proxy/proxy_server.py +++ b/litellm/proxy/proxy_server.py @@ -331,9 +331,10 @@ async def user_api_key_auth( f"LLM Model List pre access group check: {llm_model_list}" ) access_groups = [] - for m in llm_model_list: - for group in m.get("model_info", {}).get("access_groups", []): - access_groups.append((m["model_name"], group)) + if llm_model_list is not None: + for m in llm_model_list: + for group in m.get("model_info", {}).get("access_groups", []): + access_groups.append((m["model_name"], group)) allowed_models = valid_token.models if ( diff --git a/litellm/proxy/utils.py b/litellm/proxy/utils.py index e7191cafceef..ab1fea463eef 100644 --- a/litellm/proxy/utils.py +++ b/litellm/proxy/utils.py @@ -370,19 +370,21 @@ async def get_data( response = await self.db.litellm_verificationtoken.find_unique( where={"token": hashed_token} ) + if response is not None: + # for prisma we need to cast the expires time to str + if isinstance(response.expires, datetime): + response.expires = response.expires.isoformat() elif query_type == "find_all" and user_id is not None: response = await self.db.litellm_verificationtoken.find_many( where={"user_id": user_id} ) + if response is not None and len(response) > 0: + for r in response: + if isinstance(r.expires, datetime): + r.expires = r.expires.isoformat() print_verbose(f"PrismaClient: response={response}") if response is not None: - if isinstance(response, LiteLLM_VerificationToken): - # for prisma we need to cast the expires time to str - if isinstance(response.expires, datetime): - response.expires = response.expires.isoformat() - return response - else: - return response + return response else: # Token does not exist. raise HTTPException(