From 81846ffdec263267efbdd4dbcc7e4aec6f3a8489 Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Wed, 24 Jan 2024 21:49:47 -0800 Subject: [PATCH] fix(proxy/utils.py): handle item not existing during batch updates --- litellm/proxy/utils.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/litellm/proxy/utils.py b/litellm/proxy/utils.py index 789125b822..faa73d70b8 100644 --- a/litellm/proxy/utils.py +++ b/litellm/proxy/utils.py @@ -722,9 +722,14 @@ class PrismaClient: data_json = self.jsonify_object(data=user.model_dump()) except: data_json = self.jsonify_object(data=user.dict()) - batcher.litellm_usertable.update( + batcher.litellm_usertable.upsert( where={"user_id": user.user_id}, # type: ignore - data={**data_json}, # type: ignore + data={ + "create": {**data_json}, # type: ignore + "update": { + **data_json # type: ignore + }, # just update user-specified values, if it already exists + }, ) await batcher.commit() verbose_proxy_logger.info(