From 90973d92bf9e17ef5b0859cd0c343904373de19a Mon Sep 17 00:00:00 2001 From: ishaan-jaff Date: Fri, 5 Jan 2024 17:58:23 +0530 Subject: [PATCH] (fix) re-connect prisma if not connected --- litellm/proxy/utils.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/litellm/proxy/utils.py b/litellm/proxy/utils.py index 5ca8cd3b3..5670d90da 100644 --- a/litellm/proxy/utils.py +++ b/litellm/proxy/utils.py @@ -395,6 +395,10 @@ class PrismaClient: Add a key to the database. If it already exists, do nothing. """ try: + # incase prisma is not connected + if self.db.is_connected() == False: + await self.connect() + if table_name == "user+key": token = data["token"] hashed_token = self.hash_token(token=token) @@ -473,6 +477,10 @@ class PrismaClient: Update existing data """ try: + # incase prisma is not connected + if self.db.is_connected() == False: + await self.connect() + db_data = self.jsonify_object(data=data) if token is not None: print_verbose(f"token: {token}") @@ -515,6 +523,9 @@ class PrismaClient: Allow user to delete a key(s) """ try: + # incase prisma is not connected + if self.db.is_connected() == False: + await self.connect() hashed_tokens = [self.hash_token(token=token) for token in tokens] await self.db.litellm_verificationtoken.delete_many( where={"token": {"in": hashed_tokens}}