fix(proxy/utils.py): accept token hashes for deleting tokens

This commit is contained in:
Krrish Dholakia 2024-01-26 13:29:02 -08:00
parent 55b95e87dd
commit e989175c10

View file

@ -814,7 +814,13 @@ class PrismaClient:
Allow user to delete a key(s)
"""
try:
hashed_tokens = [self.hash_token(token=token) for token in tokens]
hashed_tokens = []
for token in tokens:
if isinstance(token, str) and token.startswith("sk-"):
hashed_token = self.hash_token(token=token)
else:
hashed_token = token
hashed_tokens.append(hashed_token)
await self.db.litellm_verificationtoken.delete_many(
where={"token": {"in": hashed_tokens}}
)