From b669e2987b8ac6c3f2e9b9d9f58e783abfcd5ad0 Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Thu, 18 Apr 2024 17:16:52 -0700 Subject: [PATCH] fix return key aliases on /user/info --- litellm/proxy/utils.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/litellm/proxy/utils.py b/litellm/proxy/utils.py index 3e50ba3ee5..5fafed69ad 100644 --- a/litellm/proxy/utils.py +++ b/litellm/proxy/utils.py @@ -1055,9 +1055,20 @@ class PrismaClient: }, ) else: - response = await self.db.litellm_usertable.find_many( # type: ignore - order={"spend": "desc"}, take=limit, skip=offset - ) + # return all users in the table, get their key aliases ordered by spend + sql_query = """ + SELECT + u.*, + json_agg(v.key_alias) AS key_aliases + FROM + "LiteLLM_UserTable" u + LEFT JOIN "LiteLLM_VerificationToken" v ON u.user_id = v.user_id + GROUP BY + u.user_id + LIMIT $1 + OFFSET $2 + """ + response = await self.db.query_raw(sql_query, limit, offset) return response elif table_name == "spend": verbose_proxy_logger.debug(